我正在尝试获取父文档的所有子对象,但无法通过has_child查询获得任何结果,
{
"index": "index_x",
"include_type_name": true,
"body": {
"mappings": {
"agents": {
"properties": {
"id": {
"type": "keyword"
},
"listings": {
"type": "join",
"eager_global_ordinals": true,
"relations": {
"agent": "listing"
}
},
"name": {
"type": "object"
}
}
}
}
}
}
这是我的查询
{
"query": {
"bool": {
"must": [
{
"term": {
"_id": <id>
}
},
{
"has_child": {
"type": "listing",
"query": {
"match_all": {}
},
"inner_hits": {}
}
}
]
}
}
}
但是,当我运行此查询时,我得到的子结果很好
{
"query": {
"bool": {
"must": [
{
"parent_id": {
"type":"listing",
"id": <id>
}
}
]
}
}
}
与has_parent查询相同,没有得到任何结果。我正在使用Elasticsearch 7.7
想要使用has_parent
查询的声音。这是它如何在ESv7.7上运行的最小示例:
has_parent