所以我的问题和描述的基本一样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/