如何在同一路径的多个嵌套子查询中返回多个内部匹配? [英] How to return multiple inner hits in multiple nested sub-queries for the same path?

查看:54
本文介绍了如何在同一路径的多个嵌套子查询中返回多个内部匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我对同一路径有多个嵌套子查询时,结果似乎只包括最后一个嵌套子查询的内部匹配结果.有没有办法返回多个嵌套子查询的所有内部匹配结果?

When I have multiple nested sub-queries for the same path, it seems the result will only include the inner hits result of the last nested sub-query. Is there a way to return all of the inner hits results for the multiple nested sub-queries?

例如

{
    "query": {
        "bool: {
            "must": [{
                "nested": {
                    "query": {...},
                    "path": "path_a",
                    "inner_hits": {}
                }
            },{
                "nested": {
                    "query": {...},
                    "path": "path_a",
                    "inner_hits": {}
                }
            }]
        }
    }
}

推荐答案

如果您在 inner_hits 中添加唯一的名称,则结果基本上将包含符合您的期望.

If you add a unique name to your inner_hits, then the result will basically contain a map of your inner hits as you're expecting.

注意:似乎内部匹配有时在 matched_queries 中包含额外的查询名称(来自其他嵌套查询),因此可能需要一些后处理

Note: It seems that sometimes the inner hits contains extra query names (from the other nested queries) in the matched_queries, so it may need some post-processing

这篇关于如何在同一路径的多个嵌套子查询中返回多个内部匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆