[英]Elastic search nested aggregations - method from documentation is not working
我是ES的新手,并且正在使用嵌套聚合。 这是我的虚拟数据对象([这里是我的数据对象] [1] [1]: https : //i.stack.imgur.com/X7oaM.png )。 我只是想从“现代”领域中获得最低成本。
关于我要解决的问题,我已阅读以下帖子。 他们都没有帮助我解决问题
-Elastic Search 6嵌套查询聚合-https : //www.elastic.co/guide/zh-cn/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html-https : //madewithlove.be/elasticsearch-聚合/ - https://iridakos.com/tutorials/2018/10/22/elasticsearch-bucket-aggregations.html - https://github.com/elastic/elasticsearch/issues/9317
此外,我已经在stackoverflow上进行了全面搜索,但没有获得成功( 是的 ,我尝试过几乎所有未获得成功的解决方案)。
根据文档和以上文章以及更多内容,嵌套聚合应按以下方式运行:
GET /loquesea/_search
{
"size": 0,
"aggs": {
"modern_costs": {
"nested": {
"path": "modern"
},
"aggs": {
"min_cost": {
"min": {
"field": "modern.cost1"
}
}
}
}
}
}
但是,完成后,我得到的是:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"modern_costs" : {
"doc_count" : 0
}
}
}
我已经花了几个小时尝试使基本的嵌套聚合工作正常进行。 我究竟做错了什么?
问题解决了。 事实证明,由于我没有在映射中将“汽车”的类型声明为“嵌套”,因此嵌套聚合将无法工作。 原因是在Elastic Search中,由于未将类型声明为“嵌套”,因此ES会将“汽车”视为对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.