Here是有关弹性搜索中join
类型的示例。我有插图映射,父母和孩子:
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
个字段?他们被告知已删除types
其次,我必须添加ignore_unmapped
(查看here),但仍然没有结果
那么如何通过has_child
查询弹性搜索示例中的数据来查找父项?