我试图在聚合上列出所有桶,但它似乎只显示前10个.
我的搜索:
curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d'
{
"size": 0,
"aggregations": {
"bairro_count": {
"terms": {
"field": "bairro.raw"
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
返回:
{
"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" …Run Code Online (Sandbox Code Playgroud) 我有一组280万个文档,其中包含我使用ElasticSearch查询的标记集,但其中许多文档可以通过一个ID组合在一起.我想使用标签查询我的数据,然后通过重复的ID聚合它们.我的搜索结果通常有成千上万的文档,但我只想汇总前100个搜索结果.如何将聚合仅限制为查询的前100个结果?
问题:
如果我搜索"iphone",我会得到400个产品结果和产品类别聚合,我会返回结果集中的前3个类别.
这些类别包括智能手机,手机壳和手机配件.
如果我搜索"iphone 6",我会得到1400个结果,因为额外的"6"返回匹配更多产品.产品类别聚合现在返回所有这些结果的前3个类别.
现在,前3个产品类别将是从电缆到计算机显示器的所有产品.
我需要做的是获得前100名结果的前3个类别.
我尝试过的:
我尝试top_hits在顶级类别聚合中使用聚合,但只返回每个类别中的顶级产品.
像这样的东西:
{
"aggs": {
"product_categories": {
"terms": {
"field": "product_category",
"size": 10,
}
}
"aggs": {
"top-categories": {
"top_hits": {
"size" : 3
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试创建一个top_hits带有子聚合的聚合来获得最高类别,但这也不起作用.
{
"aggs": {
"top-categories": {
"top_hits": {
"size" : 100
}
"aggs": {
"product_categories": {
"terms": {
"field": "product_category",
"size": 3,
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?