【问题标题】:Elastic search nested aggregations - method from documentation is not working弹性搜索嵌套聚合 - 文档中的方法不起作用
【发布时间】:2019-06-18 15:10:24
【问题描述】:

我是 ES 新手,正在为嵌套聚合而苦苦挣扎。 这是我的虚拟数据对象([这是我的数据对象][1][1]:https://i.stack.imgur.com/X7oaM.png)。我只是想从“现代”领域中获得最低成本。

关于我要解决的问题,我已阅读以下帖子。他们都没有帮助我解决问题
- Elastic Search 6 Nested Query Aggregations - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html - https://madewithlove.be/elasticsearch-aggregations/ - 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
    }
  }
}

我花了好几个小时试图让一个基本的嵌套聚合工作。我做错了什么?

【问题讨论】:

    标签: elasticsearch nested aggregation


    【解决方案1】:

    问题解决了。事实证明,由于我没有在映射中将“汽车”的类型声明为“嵌套”,因此嵌套聚合将不起作用。原因是在 Elastic Search 中,由于类型未声明为“嵌套”,ES 会将“汽车”视为对象。

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多