显示所有Elasticsearch聚合结果/桶,而不只是10

编程入门 行业动态 更新时间:2024-10-26 00:26:43
本文介绍了显示所有Elasticsearch聚合结果/桶,而不只是10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试列出汇总上的所有存储桶,但似乎只显示前10个。

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

返回: p>

{take:2,timed_out:false,_shards :{total:5,success:5,failed:0 },hits:{ total:16920,max_score:0.0,hits:[] },聚合:{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 },{关键:Flamengo,doc_count:328 }] } } } pre>

我有超过10个密钥用于此聚合。在这个例子中,我有145个键,我想要每个键的计数。桶上有分页吗?我可以得到所有的吗?

我使用的是Elasticsearch 1.1.0

解决方案

大小参数应该是术语查询示例的参数:

curl -XPOSThttp:// localhost:9200 / imoveis / _search?pretty = 1-d' {size:0,aggregations:{bairro_count:{条款:{field:bairro.raw,size:0 } } } } '

正如文档中提到的,仅适用于1.1.0以前版本

编辑

根据@PhaedrusTheGreek评论更新答案。

设置 size:0 在2.x之后已被弃用,因为您的群集上存在高基数字段值造成内存问题。您可以在github 问题这里了解更多信息。

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

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

My search:

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

Returns:

{ "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 } ] } } }

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?

I'm using Elasticsearch 1.1.0

解决方案

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

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

As mentioned in the doc works only for version 1.1.0 onwards

Edit

Updating the answer based on @PhaedrusTheGreek comment.

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 .

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

更多推荐

显示所有Elasticsearch聚合结果/桶,而不只是10

本文发布于:2023-10-12 21:04:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不   Elasticsearch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!