elasticsearch仅从索引获取父文档

时间:2020-04-09 18:52:11

标签: elasticsearch

我正在尝试从索引中获取所有父文档。 有什么办法吗?

我已经尝试过了:

BeanManager

这:

"must": [
    {
      "nested": {
        "path": "join",
        "query": {
          "match": {
            "name": "post"
          }
        }
      }
    }
  ]

1 个答案:

答案 0 :(得分:0)

索引中记录的每个子项都有_routing字段。 如果我只希望父文档,则它们必须没有_routing字段。 因此我将在查询中添加“ must_not”,以确保带有_routing字段的文档不会返回。

解决方案:

"must_not": [
    {
      "exists": {
        "field": "_routing"
      }
    }
  ]