首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >显示所有Elasticsearch聚合结果/存储桶,而不仅仅是10个

显示所有Elasticsearch聚合结果/存储桶,而不仅仅是10个
EN

Stack Overflow用户
提问于 2014-04-08 11:41:33
回答 2查看 108.8K关注 0票数 208

我试图列出聚合上的所有存储桶,但似乎只显示了前10个存储桶。

我的搜索结果:

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

返回:

代码语言:javascript
复制
{
  "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个关键点,我想知道每个关键点的数量。存储桶上有分页吗?我能把它们都买下来吗?

我使用的是Elasticsearch 1.1.0

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-04-08 11:55:26

对于术语查询示例,size param应为param:

代码语言:javascript
复制
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

由于高基数字段值对集群造成的内存问题,2.x及更高版本中不建议设置size:0。你可以在github issue here上阅读更多关于它的内容。

建议显式设置size的合理值,取值范围为1到2147483647。

票数 238
EN

Stack Overflow用户

发布于 2018-09-09 16:58:52

将术语聚合中的大小(第二个大小)增加到10000,您将获得大小为10000的存储桶。默认情况下,它被设置为10。另外,如果您想查看搜索结果,请将第一个大小设置为1,您可以看到1个文档,因为ES同时支持搜索和聚合。

代码语言:javascript
复制
curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d'
{
   "size": 1,
   "aggregations": {
      "bairro_count": {
         "terms": {
             "field": "bairro.raw",
             "size": 10000

         }
      }
   }
}'
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22927098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档