# CRM Search API OR Logic Reducing Results

**URL:** <https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, contacts\
**Created:** [February 5, 2025, 11:22pm UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510 "2025-02-05T23:22:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJohnson59](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MJohnson59](https://community.hubspot.com/u/MJohnson59)\
**Post date:** [February 5, 2025, 11:22pm UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510/1 "2025-02-05T23:22:29Z")

</div>

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.

```lia-code-sample
{
 "filterGroups": [
 {
 "filters": [
 {
 "propertyName": "hs_analytics_last_visit_timestamp",
 "operator": "GT",
 "value": "1738540800000"
 }
 ]
 }
 ]
}

```

Adding OR logic returns 474 total:

```lia-code-sample
{
 "filterGroups": [
 {
 "filters": [
 {
 "propertyName": "hs_analytics_last_visit_timestamp",
 "operator": "GT",
 "value": "1738540800000"
 }
 ],
 "filters": [
 {
 "propertyName": "hs_analytics_last_timestamp",
 "operator": "GT",
 "value": "1738540800000"
 }
 ]
 }
 ]
}​

```

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [February 6, 2025, 9:27am UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510/2 "2025-02-06T09:27:30Z")

</div>

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](https://developers.hubspot.com/docs/api-reference/legacy/account/settings/user-provisioning/guide)

 ![GRajput_0-1738833990760.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/e/eb359d7d7b43ec08b66788961a1bc00af00fe2bd.png)

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

---

<div class="post-metadata">

**Author:** ![MJohnson59](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MJohnson59](https://community.hubspot.com/u/MJohnson59)\
**Post date:** [February 6, 2025, 2:07pm UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510/3 "2025-02-06T14:07:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![evaldas](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/evaldas/32/69160_2.png) [@evaldas](https://community.hubspot.com/u/evaldas)\
**Post date:** [February 6, 2025, 4:03pm UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510/4 "2025-02-06T16:03:54Z")

</div>

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?

```lia-code-sample
{
 "filterGroups": [
 {
 "filters": [
 {
 "propertyName": "hs_analytics_last_visit_timestamp",
 "operator": "GT",
 "value": "1738540800000"
 }
 ]
 },
 {
 "filters": [
 {
 "propertyName": "hs_analytics_last_timestamp",
 "operator": "GT",
 "value": "1738540800000"
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![MJohnson59](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MJohnson59](https://community.hubspot.com/u/MJohnson59)\
**Post date:** [February 6, 2025, 4:05pm UTC](https://community.hubspot.com/t/crm-search-api-or-logic-reducing-results/125510/5 "2025-02-06T16:05:56Z")

</div>

That was it! Thank you @evaldas
