4

Consider an Algolia index filled with objects like this:

{ 
   "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 right query to get all objects that have contributor_ids 42 AND contributor_ids=12 ?

4

1 回答 1

9

默认行为是 AND,您可以使用带括号的 OR:

numericFilters: "contributor_ids=42, contributor_ids=12"

表示contributor_ids=42 ANDcontributor_ids=12,仅当您的记录包含这两个值时才匹配

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

表示contributor_ids=42 或contributor_ids=12

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

表示contributor_ids=10 AND (contributor_ids=42 OR contributor_ids=12)

于 2015-08-06T09:52:24.227 回答