gpt4 book ai didi

elasticsearch - 在elasticsearch中寻找 child parent

转载 作者:行者123 更新时间:2023-12-02 22:52:43 26 4
gpt4 key购买 nike

如果我在 flex 搜索中有 child - parent 映射。
我将如何根据子女的统计信息寻找 parent 。

例:

{
'parent':{
'_id':{
'path':'parent_id'
},
'properties':{
'parent_id':{
'type':'string'
},
'name':{
'type':'string'
},
'job':{
'type':'string'
},
'age':{
'type':'integer'
},

}
}
}{
'child':{
'_parent':{
'type':'parent'
},
'_id':{
'path':'child_id'
},
'properties':{
'child_id':{
'type':'string'
},
'name':{
'type':'string'
},
'favorite_toy':{
'type':'string'
},
'age':{
'type':'integer'
},

}
}
}

我将如何:
  • 获取所有有一个名为“bob”的 child 的 parent 吗?
  • 数所有有一个名为“bob”的 child 的 parent 吗?
  • 得到所有有两个以上 child 的 parent 吗?
  • 获取所有有2个5岁以上的 child 的 parent 吗?
  • 最佳答案

    1)和2)-您只需将查询包装成has_child查询即可:

    {
    "has_child":{
    "type":"child",
    "query":{
    "match":{
    "name":"bob"
    }
    }
    }
    }

    3)和4)-我目前认为这不可能。

    关于elasticsearch - 在elasticsearch中寻找 child parent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15116711/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com