显示所有Elasticsearch聚合结果/桶,而不只是10 [英] Show all Elasticsearch aggregation results/buckets and not just 10
问题描述
我正在尝试列出汇总上的所有存储桶,但似乎只显示前10个。
curl -XPOSThttp:// localhost:9200 / imoveis / _search?pretty = 1-d'
{
size:0,
aggregate:{
bairro_count:{
terms:{
field:bairro.raw
}
}
}'
返回: p>
{
pre>
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
}]
}
}
}
我有超过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 "http://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 "http://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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文