本书基于 Elasticsearch 2.x 版本,有些内容可能已经过时。 Elasticsearch: 权威指南 » 聚合 » 多桶排序 » 内置排序 « 多桶排序 按度量排序 »
内置排序编辑
这些排序模式是桶 固有的 能力:它们操作桶生成的数据
,比如 doc_count
。
它们共享相同的语法,但是根据使用桶的不同会有些细微差别。
让我们做一个 terms
聚合但是按 doc_count
值的升序排序:
GET /cars/transactions/_search { "size" : 0, "aggs" : { "colors" : { "terms" : { "field" : "color", "order": { "_count" : "asc" } } } } }
用关键字 _count
,我们可以按 doc_count
值的升序排序。
我们为聚合引入了一个 order
对象, 它允许我们可以根据以下几个值中的一个值进行排序:
_count
按文档数排序。对 terms
、 histogram
、 date_histogram
有效。
_term
按词项的字符串值的字母顺序排序。只在 terms
内使用。
_key
按每个桶的键值数值排序(理论上与 _term
类似)。
只在 histogram
和 date_histogram
内使用。
«
多桶排序
按度量排序
»
Getting Started Videos
Starting Elasticsearch Introduction to Kibana Logstash Starter Guide官方地址:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_intrinsic_sorts.html