Reputation: 11299
I've got records in Algolia containing an array attribute with integer values, like :
{
...
choice_ids: [1, 99, 100, 200]
...
}
I want to filter all records containing any value of another array. For example I search for [1, 300, 400, 600, 700], I should get the record on top because it contains 1.
Should I construct the filter with OR arguments or is there a better way?
Upvotes: 9
Views: 3291
Reputation: 503
For me, neither of @Léo Chaz Maltrait or @redox answers worked. I had to format mine like:
{ filters: '(choice_ids:"1") OR (choice_ids:"99" OR (choice_ids:"100") OR (choice_ids:"200"))' })
I am also using algoliasearch
npm package.
Upvotes: 0
Reputation: 669
For me it wasn't working with '=' but with ':', meaning:
{ filters: 'choice_ids:1 OR choice_ids:99 OR choice_ids:100 OR choice_ids:200' })
Upvotes: 1
Reputation: 2309
Should I construct the filter with OR arguments or is there a better way?
Yes that's the way to go.
index.search('....', { filters: '(choice_ids=1 OR choice_ids=99 OR choice_ids=100 OR choice_ids=200)' });
Upvotes: 13