嗨,我正在尝试在其他字段中搜索值。我正在将multi_match与cross_fields类型一起使用。
这是查询
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "red cross",
"type": "cross_fields",
"fields": [
"name^20",
"keywords^12",
"description^1"
]
}
}
]
}
}
} }
我得到上述查询的结果
"results": [
{
"name": "CrossPurpose",
.....
} ,
{
"name": "Community Center",
"keywords": "American Red Cross,Red Cross,Center,Blood",
. . .
},
{
"name": "Some Group",
"description":".... red cross ..."
},
.......
....
..
{
"name" : "Red cross" ,
.....
}
]
我想改善搜索结果。
我想在第一个位置看到名称为“红十字”的记录。
首先,它应与整个单词“red cross”匹配,然后仅应与“red”,“cross”匹配。
我希望名称字段的优先级高于关键字和描述的优先级。
请帮我改进查询。
提前致谢。
最佳答案
您需要使用type = best_fields
因此您的查询将是
{
"query": {
"multi_match" : {
"query": "red cross",
"type": "best_fields",
"fields": [ "name", "keywords", "description" ],
"tie_breaker": 0.3
}
}
}
关于elasticsearch - Elasticsearch:改善多重比赛结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50250508/