[英]How can I get max and min numeric value with in the search in algolia
我试图将我的日期范围过滤器限制在结果的最大和最小日期值中(整个结果不只是首页),algolia是否有办法返回返回值中该值的最小和最大值注意:其数字属性不是构面
If one of the facets you defined contains numerical values, the API response will contain a facets_stats
key. 如果您定义的方面之一包含数值,则API响应将包含
facets_stats
键。 It's an object with one key per facet, and each of those keys contains the following informations: min
, max
, avg
and sum
. 它是一个对象,每个面都有一个键,并且每个键都包含以下信息:
min
, max
, avg
和sum
。
You can find more informations about the API response format in the doc . 您可以在doc中找到有关API响应格式的更多信息。
The JS Helper actually has a getFacetStats method to get that data. JS Helper实际上有一个getFacetStats方法来获取该数据。
Note that those values are dynamic, and relative to the others filters currently applied (ie. they are the min and max values of the items that currently match your query ). 请注意,这些值是动态的,并且相对于当前应用的其他过滤器而言(即,它们是当前与您的查询匹配的项目的最小值和最大值)。 If you want the absolute min and max of all the items in your index, you will have to do first an empty query (no filters, no keyword) and save those min/max somewhere.
如果要获取索引中所有项目的绝对最小值和最大值,则必须首先执行一个空查询(没有过滤器,没有关键字),然后将这些最小值/最大值保存在某个地方。
You have to add you attribute to the attributesForFacetting
for this to work. 您必须将属性添加到
attributesForFacetting
才能起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.