作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何为 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/
我正在寻找一种方法来实现具有同义词和模糊性的自动建议 例如,当用户试图搜索“replce ar”时我的同义词列表有 ar => 录音 所以,结果应该包括匹配的项目改变录音更换录音等等, 这里我们需要模
是否可以将模糊与词条查询一起使用而不匹配? 让我解释: 假设我们有4个文件 { "index": { "_id": 1 }} { "text": "I play football!"} { "inde
我在查询字符串中指定了一个 fuzzy_prefix_length,但是搜索“tes”并没有提取标题为“test”的帖子……知道我做错了什么吗? 这是我的查询字符串设置 "query" : { "
我是一名优秀的程序员,十分优秀!