如何在 ES 6.0 中对示例执行 has_child 查询

How perform has_child query for examples in ES 6.0

Here 是 elasticsearch 中关于 join 类型的例子。我有插入映射,parents 和 children:

PUT my_index
{
  "mappings": {
    "doc": {
      "properties": {
        "my_join_field": {
          "type": "join",
          "relations": {
            "question": "answer"
          }
        }
      }
    }
  }
}

PUT my_index/doc/1?refresh
{
  "text": "This is a question",
  "my_join_field": {
    "name": "question"
  }
}

PUT my_index/doc/2?refresh
{
  "text": "This is a another question",
  "my_join_field": {
    "name": "question"
  }
}

PUT my_index/doc/1?refresh
{
  "text": "This is a question",
  "my_join_field": "question"
}

PUT my_index/doc/2?refresh
{
  "text": "This is another question",
  "my_join_field": "question"
}

现在我正在尝试通过 children:

搜索 parents
GET /my_index/doc/_search
{
  "query": {
    "has_child": {
      "type": "my_join_field",
      "query": {
        "match" : {
          "text": "question"
        }
      },
      "ignore_unmapped": true
    }
  },
  "highlight" : {
    "fields" : {
      "content" : {}
    }
  }
}

我没有得到任何结果。 :( >:(

首先 type 字段应该是什么???他们被告知 types 已被删除 其次,我必须添加ignore_unmapped(看起来here)但仍然没有结果

那么在elasticsearch例子中如何通过has_child查询数据找到parent?

查看11_parent_child.yml 文件。它包含父项、子项的索引并对子项执行查询。它是 yaml,但我认为转换为 json 是显而易见的。