ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

22、Elasticsearch 中的分面搜索与建议器使用指南

22、Elasticsearch 中的分面搜索与建议器使用指南

Elasticsearch 中的分面搜索与建议器使用指南

1. 数值和日期直方图分面

直方图分面允许我们基于字段值(数值和日期字段)的区间构建直方图。例如,若想查看total字段中落入每 1000 区间的文档数量,可运行以下查询:

{ "query": { "match_all": {} }, "facets": { "total_histogram": { "histogram": { "field": "total", "interval": 1000 } } } }

响应示例如下:

{ (...) "facets": { "total_histogram": { "_type": "histogram", "entries": [ { "key": 0, "count": 18565 }, { "key": 1000, "count": 33 }, { "key": 2000, "count": 14 }, { "key": 3000, "count": 5 }, (.
返回列表