1

join是关于在 elasticsearch 中键入的示例。我有插入映射,父母和孩子:

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"
}

现在我正在尝试按孩子搜索父母:

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

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

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

那么如何通过has_child查询elasticsearch示例中的数据来找到父级呢?

4

1 回答 1

0

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

于 2018-03-10T10:52:49.703 回答