gpt4 book ai didi

具有模糊性的多个字段的 ElasticSearch multi_match 查询

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

如何为 multi_match 查询添加模糊性?因此,如果有人要搜索“basball”,它仍然会找到“baseball”文章。目前我的查询是这样的:

POST /newspaper/articles/_search
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "baseball",
"type": "phrase",
"fields": [
"subject^3",
"section^2.5",
"article^2",
"tags^1.5",
"notes^1"
]
}
}
}
}
}

我正在考虑的一种选择是做这样的事情,只是不知道这是否是最佳选择。保持基于评分的排序很重要:

   "query" : { 
"query_string" : {
"query" : "subject:basball^3 section:basball^2.5 article:basball^2",
"fuzzy_prefix_length" : 1
}
}

建议?

最佳答案

要向多查询添加模糊性,您需要按照此处所述添加模糊性属性:

{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "baseball",
"type": "phrase",
"fields": [
"subject^3",
"section^2.5",
"article^2",
"tags^1.5",
"notes^1"
],
"fuzziness" : "AUTO",
"prefix_length" : 2

}
}
}
}
}

请注意 prefix_length 在文档中解释为:

不会被“模糊化”的初始字符数。这有助于减少必须检查的术语数量。默认为 0。

要检查模糊度 的可能值,请访问 ES docs .

关于具有模糊性的多个字段的 ElasticSearch multi_match 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29632339/

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