Algolia 过滤器相当于数组的 SQL IN?
Algolia filter equivalent to SQL IN for arrays?
我在 Algolia 中获得了包含具有整数值的数组属性的记录,例如:
{
...
choice_ids: [1, 99, 100, 200]
...
}
我想过滤所有包含另一个数组的任何值的记录。例如我搜索 [1, 300, 400, 600, 700],我应该把记录放在最上面,因为它包含 1.
我应该用 OR 参数构建过滤器还是有更好的方法?
Should I construct the filter with OR arguments or is there a better way?
是的,就是这样。
index.search('....', { filters: '(choice_ids=1 OR choice_ids=99 OR choice_ids=100 OR choice_ids=200)' });
对我来说,它不是与“=”一起工作,而是与“:”一起工作,意思是:
{ filters: 'choice_ids:1 OR choice_ids:99 OR choice_ids:100 OR choice_ids:200' })
对我来说,@Léo Chaz Maltrait 或@redox 的回答都没有用。我必须像这样格式化我的格式:
{ filters: '(choice_ids:"1") OR (choice_ids:"99" OR (choice_ids:"100") OR (choice_ids:"200"))' })
我也在使用 algoliasearch
npm 包。
我在 Algolia 中获得了包含具有整数值的数组属性的记录,例如:
{
...
choice_ids: [1, 99, 100, 200]
...
}
我想过滤所有包含另一个数组的任何值的记录。例如我搜索 [1, 300, 400, 600, 700],我应该把记录放在最上面,因为它包含 1.
我应该用 OR 参数构建过滤器还是有更好的方法?
Should I construct the filter with OR arguments or is there a better way?
是的,就是这样。
index.search('....', { filters: '(choice_ids=1 OR choice_ids=99 OR choice_ids=100 OR choice_ids=200)' });
对我来说,它不是与“=”一起工作,而是与“:”一起工作,意思是:
{ filters: 'choice_ids:1 OR choice_ids:99 OR choice_ids:100 OR choice_ids:200' })
对我来说,@Léo Chaz Maltrait 或@redox 的回答都没有用。我必须像这样格式化我的格式:
{ filters: '(choice_ids:"1") OR (choice_ids:"99" OR (choice_ids:"100") OR (choice_ids:"200"))' })
我也在使用 algoliasearch
npm 包。