How to use AND and OR when using an Algolia numerical filter

Consider the Algolia index filled with such objects:

{ "objectID": 1, "name": "My project title", "contributor_ids": [12, 42, 34] } 

Does this query get all objects that have contributor_ids 42 or contributor_ids = 12?

 "numericFilters: 'contributor_ids=42, contributor_ids=12" 

And if so, what is the correct request to get all objects that have contributor_ids 42 and contributor_ids = 12?

+4
source share
1 answer

The default behavior is AND, you can have an OR bracket:

 numericFilters: "contributor_ids=42, contributor_ids=12" 

The values ​​contributor_ids = 42 and contributor_ids = 12 are only relevant if you have an entry containing both values

 numericFilters: "(contributor_ids=42, contributor_ids=12)" 

Means contributor_ids = 42 OR contributor_ids = 12

 numericFilters: "contributor_ids=10,(contributor_ids=42, contributor_ids=12)" 

Means contributor_ids = 10 AND (contributor_ids = 42 OR contributor_ids = 12)

+8
source

All Articles