gpt4 book ai didi

elasticsearch - 如何在 Elasticsearch 中提高精确匹配而不是多重匹配

转载 作者:行者123 更新时间:2023-11-29 02:44:27 25 4
gpt4 key购买 nike

我正在运行以下查询以提高 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com