When using the CRM Search with OR logic, additional filters are reducing results, but OR should never reduce a result set, it should only ever increase or stay the same.
What am I missing?
Example filter bodies below:
Returns 475 as a total.
{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_analytics_last_visit_timestamp",
"operator": "GT",
"value": "1738540800000"
}
]
}
]
}
Adding OR logic returns 474 total:
{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_analytics_last_visit_timestamp",
"operator": "GT",
"value": "1738540800000"
}
],
"filters": [
{
"propertyName": "hs_analytics_last_timestamp",
"operator": "GT",
"value": "1738540800000"
}
]
}
]
}
Hi @MJohnson59
To apply OR logic, include multiple filters within a filter group. You can include a maximum of five filter groups with up to 6 filters in each group, with a maximum of 18 filters in total.
here is the link to the doc : https://developers.hubspot.com/docs/guides/api/crm/search
I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!
@GRajput thanks!
However, unless I’m mistaken, I am already applying the OR logic. My concern is that it’s not working as I would imagine.
OR is reducing the result set when I would expect it to always only increase, or in the case of no data returned from Or, stay the same.
But when I use the OR logic in my original example I’m see fewer results returned.
Hi @MJohnson59,
It looks like you might be missing a couple of curly brackets, which creates AND logic between the two filters.
Can you see if this updated version returns more results?
{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_analytics_last_visit_timestamp",
"operator": "GT",
"value": "1738540800000"
}
]
},
{
"filters": [
{
"propertyName": "hs_analytics_last_timestamp",
"operator": "GT",
"value": "1738540800000"
}
]
}
]
}
That was it! Thank you @evaldas