显示所有 Elasticsearch 聚合结果/存储桶,而不仅仅是 10 个 [英] Show all Elasticsearch aggregation results/buckets and not just 10

查看:39
本文介绍了显示所有 Elasticsearch 聚合结果/存储桶,而不仅仅是 10 个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试列出聚合中的所有存储桶,但它似乎只显示前 10 个.

I'm trying to list all buckets on an aggregation, but it seems to be showing only the first 10.

我的搜索:

curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d'
{
   "size": 0, 
   "aggregations": {
      "bairro_count": {
         "terms": {
            "field": "bairro.raw"
         }
      }
   }
}'

返回:

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 16920,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "aggregations" : {
    "bairro_count" : {
      "buckets" : [ {
        "key" : "Barra da Tijuca",
        "doc_count" : 5812
      }, {
        "key" : "Centro",
        "doc_count" : 1757
      }, {
        "key" : "Recreio dos Bandeirantes",
        "doc_count" : 1027
      }, {
        "key" : "Ipanema",
        "doc_count" : 927
      }, {
        "key" : "Copacabana",
        "doc_count" : 842
      }, {
        "key" : "Leblon",
        "doc_count" : 833
      }, {
        "key" : "Botafogo",
        "doc_count" : 594
      }, {
        "key" : "Campo Grande",
        "doc_count" : 456
      }, {
        "key" : "Tijuca",
        "doc_count" : 361
      }, {
        "key" : "Flamengo",
        "doc_count" : 328
      } ]
    }
  }
}

我有超过 10 个用于此聚合的键.在这个例子中,我有 145 个键,我想要每个键的计数.桶上有分页吗?我可以全部拿到吗?

I have much more than 10 keys for this aggregation. In this example I'd have 145 keys, and I want the count for each of them. Is there some pagination on buckets? Can I get all of them?

我使用的是 Elasticsearch 1.1.0

I'm using Elasticsearch 1.1.0

推荐答案

size param 应该是terms 查询示例的参数:

The size param should be a param for the terms query example:

curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d'
{
   "size": 0,
   "aggregations": {
      "bairro_count": {
         "terms": {
            "field": "bairro.raw",
             "size": 10000
         }
      }
   }
}'

对 ES 版本 2 及更早版本使用 size: 0.

Use size: 0 for ES version 2 and prior.

设置 size:0 在 2.x 之后已弃用,因为具有高基数字段值的集群会出现内存问题.您可以在 github issue here 中阅读更多相关信息.

Setting size:0 is deprecated in 2.x onwards, due to memory issues inflicted on your cluster with high-cardinality field values. You can read more about it in the github issue here .

建议为 size 明确设置合理的值,一个介于 1 到 2147483647 之间的数字.

It is recommended to explicitly set reasonable value for size a number between 1 to 2147483647.

这篇关于显示所有 Elasticsearch 聚合结果/存储桶,而不仅仅是 10 个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆