我很难在弹性搜索中进行连接查询。我的用例在子文档中被赋予了一个特定的字段和值,检索父文档。
我已经在文档之后的两个文档之间建立了父子关系。当我尝试查询时,我没有收到错误,但我也没有得到任何结果。以下是查询
GET my_index/_search
{
"query": {
"has_parent" : {
"parent_type" : "<parent_type>",
"query" : {
"match" : {
"name": "child_name"
}
}
}
}
}
我已经在同一个索引“my_index”中加载了父文档和子文档。我已经在加载文档之前建立了映射。我的映射如下
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"parent_join": {
"type": "join",
"relations": {
"<parent_type>": "<child_type>"
}
}
}
}
}
}
我在加载文档时添加了路由号码作为父 ID。