Filtering Promotions by Market using custom field

I’m trying to add a query rule that would allow me to only display certain promotions if a market is indicated on that promotion through a custom field. If no markets are indicated then the desired behavior would be to display that promotion regardless of the market in the context parameters of the search.

The query rule I set up allows me to only display a test promo if the market matches what is set on that test promo. However, for all other promotions that doesn’t have any markets indicated on the custom field, they no longer display in search when the market is set in the context parameter.

Is there a way to write this query rule but have it return all promotions if the context contains the market & the promotion entities don’t have any markets indicated on the custom field?

This is the query rule I was using:

Context contains $.market

{
“actionType”: “ADD_FILTER”,
“filter”: {
“c_promoMarket”: {
“$eq”: “{{$.market}}”
}
},
“verticals”: [
“promotions”
]
}

Hi Andrew, thanks for your question. I’m currently looking into this and will let you know once I have a good answer. Thanks for your patience!

Hi Andrew - sorry, we do not support searching on null/empty values. One thing you could try is to bulk edit the promotions without a c_promoMarket field value to have a placeholder value, like ‘N/A’ or ‘No Market’, then use a $or operator in your filter. Let me know if that shows the behavior you’re looking for.

We appreciate your patience!

Hi Chris - Thanks for the quick response. How would that look in the json based on the sample I provided? I can give it a try!

Hi Andrew,

Sorry! It should actually be the logical $or operator, my fault. You should be able to do that by mimicking this:

“filter”: {
“$or”: {
“fieldName”: {
“$eq”: “{{$.value}}”
},
“fieldName”: {
“$eq”: “{{some other value}}”
}
}

Let me know if that works for you. Thanks!

Realized the syntax above was incorrect and won’t let me edit. The logical ‘or’ syntax for this scenario would look like this. Note that we were using the curly object brackets before which was incorrect.

{
“actionType”: “ADD_FILTER”,
“filter”: {
“$or”: [
{
“c_promoMarket”: {
“$eq”: “{{$.market}}”
}
},
{
“c_promoMarket”: {
“$eq”: “n/a”
}
}
]
},
“verticals”: [
“promotions”
]
}

1 Like