elasticsearch - Elastic Search 嵌套多匹配查询

标签 elasticsearch nested match nested-properties

所以我的问题和描述的基本一样here , 但是在群组中仍未得到答复。

我的映射:

{
    "abstract": {
        "properties": {
            "summary": {
                "type": "string"
            }
        }
    },
    "authors": {
        "type": "nested",
        "properties": {
            "first_name": {
                "type": "string"
            },
            "last_name": {
                 "type": "string"
            }
        }
    }
}

我想对这两个字段执行全文搜索,可能权重不均。我想到的查询是这样的,但不幸的是它不起作用:

{
    "query": {
        "bool": {
            "should": [{
                "multi_match": {
                    "query": "higgs boson",
                    "fields": ["abstract.summary^5", "author.last_name^2"]
                }
            }]
        }
    }
}

由于其嵌套映射,我没有从作者字段中获得任何结果。我也无法摆脱嵌套属性——我将它用于聚合。任何优雅的想法如何解决它?

最佳答案

我设法解决的唯一解决方案,既不方便也不优雅,但不知何故有效,就是这样的查询:

"query": {
    "bool": {
        "should": [
            {
                "nested": {
                    "path": "authors",
                    "query": {
                        "multi_match": {
                            "query": "higgs",
                            "fields": ["last_name^2"]
                        }
                    }
                } 
            },
            {
                "multi_match": {
                    "query": "higgs",
                    "fields": ["abstract.summary^5"]
                }
            }
        ]
    }
}

我也不确定提升是否会按预期工作,前提是它是在不同的查询中设置的。任何建议表示赞赏。

关于elasticsearch - Elastic Search 嵌套多匹配查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31829654/

相关文章:

performance - 大字段名称和日期类型对Elasticsearch的性能影响

c# - 如何去: Indexing a child for elasticsearch with c# and elasticsearch.网?

java - 打印偶数矩阵对角线

MySQL Select Distinct 并计算每个不同条件匹配条件的数量

google-chrome - 与所有 google 等顶级域匹配的内容脚本。*

regex - Ruby - 仅匹配和替换电子邮件中的特定字符

Elasticsearch:将 match_phrase 和 match 结合起来,以便仅获取 match_phrase 的结果(如果有)

elasticsearch - 使用 'and'和 'or'进行过滤的elasticsearch语法错误

c++ - 如何获得 n 嵌套 vector 的最内层类型?

java - 作为 n 的函数,确定递增变量计数的语句执行的频率