Return 仅查询具有在 Algolia 中设置显式值的属性

Return only queries with an attribute set an explicit value in Algolia

是否可以设置 Algolia 的前端,使其仅 return 具有传递属性等于明确设置值的结果以及用户查询?

所以用户查询 red shoes,但我只想给他们匹配 red shoesprices.isHigh 等于 20 的结果(作为例如)?

我正在考虑传递 attributesToRetrieve: 'prices.isHigh:20'numericFilters: 'prices.isHigh:20' 之类的东西。使用 JavaScript API.

这些都行吗?

您给出问题的答案:

{
  query: 'red shoes',
  numericFilters: 'prices.isHigh=20'
}

attributesToRetrieve on the other hand is used to restrict which attributes you want in the response to reduce the JSON size and can be overriden at query time. It expect a list of attributes. For security purposes, you can instead set the unretrievableAttributes 不可覆盖的索引设置。