我正在运行以下查询以提高 Elasticsearch 中 multi_match 的精确匹配。但是,没有得到预期的结果。
我的目标是按以下顺序提升:“java developer”> java AND developer > java OR developer
有人可以帮助解决这个问题吗?需要知道如何在此处提升 match_phrase 以及如何在 match_phrase 中添加剩余字段
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
]
}
}
],
"should": [
{
"match_phrase": {
"title": "java developer"
}
},
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"operator": "and",
"boost": 4
}
}
]
}
}
非常感谢您的帮助。
最佳答案
这是对我有用的:
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
]
}
}
],
"should": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"type": "phrase",
"boost": 10
}
},
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"operator": "and",
"boost": 4
}
}
]
}
}
关于elasticsearch - 如何在 Elasticsearch 中提高精确匹配而不是多重匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31825928/