APIs & Integrations

MJohnson59
Member

CRM Search API OR Logic Reducing Results

SOLVE

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"
        }
      ]
    }
  ]
}​

 



1 Accepted solution
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

CRM Search API OR Logic Reducing Results

SOLVE

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"
        }
      ]
    }
  ]
}

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

4 Replies 4
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

CRM Search API OR Logic Reducing Results

SOLVE

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"
        }
      ]
    }
  ]
}

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

MJohnson59
Member

CRM Search API OR Logic Reducing Results

SOLVE

That was it! Thank you @evaldas 

GRajput
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

CRM Search API OR Logic Reducing Results

SOLVE

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

 

GRajput_0-1738833990760.png

 

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

 

 

 




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


0 Upvotes
MJohnson59
Member

CRM Search API OR Logic Reducing Results

SOLVE

@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.