我在检索我的“祖父母”项的inner_hits
时遇到问题。来自子查询的父项工作正常,但不能让它也返回更高一级的项。
有什么想法吗?
known issue现在应该是固定的(2.3),workaround是根据嵌套对象编写的,而不是父/子层次结构数据,所以不能让它为我工作。
有意义格式的代码:
POST /test/child/_search
{
"query": {
"has_parent": {
"type": "parent",
"query": {
"has_parent": {
"type": "grandparent",
"query": {
"match_all": {}
},
"inner_hits": {}
}
},
"inner_hits": {}
}
}
}
PUT /test/child/3?parent=2&routing=1
{
"id": 3,
"name": "child",
"parentid": 2
}
PUT /test/parent/2?parent=1&routing=1
{
"id": 2,
"name": "parent",
"parentid": 1
}
PUT /test/grandparent/1
{
"id": 1,
"name": "grandparent"
}
PUT /test
{
"mappings": {
"grandparent": {},
"parent": {
"_parent": {
"type": "grandparent"
}
},
"child": {
"_parent": {
"type": "parent"
}
}
}
}
1条答案
按热度按时间tct7dpnv1#
这是用于查找祖父级的示例代码