我试图列出聚合上的所有存储桶,但似乎只显示了前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个关键点,我想知道每个关键点的数量。存储桶上有分页吗?我能把它们都买下来吗?
我使用的是Elasticsearch 1.1.0
发布于 2014-04-08 11:55:26
对于术语查询示例,size param应为param:
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。
发布于 2018-09-09 16:58:52
将术语聚合中的大小(第二个大小)增加到10000,您将获得大小为10000的存储桶。默认情况下,它被设置为10。另外,如果您想查看搜索结果,请将第一个大小设置为1,您可以看到1个文档,因为ES同时支持搜索和聚合。
curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d'
{
"size": 1,
"aggregations": {
"bairro_count": {
"terms": {
"field": "bairro.raw",
"size": 10000
}
}
}
}'
https://stackoverflow.com/questions/22927098
复制相似问题