亲,只收二进制

ElasticSearch 模糊词序搜索

Elasticsearch | 作者 jiangzeyin | 发布于2020年11月28日 | 阅读数:1342

 
版本:6.7.0
运行环境:java + RestHighLevelClient
 
场景:例如在搜索 【中文社区】时候 误输入为【中文区社】 时候怎么能实现搜索到对应内容呢?


使用 query_string 能实现吗?
 
GET /xxxxx/_search
{
"query": {
"query_string": {
"default_field": "nickname",
"query": "中文区社",
"default_operator": "OR",
"phrase_slop": 10000,
"allow_leading_wildcard": true,
"analyze_wildcard": true,
"lenient": true,
"minimum_should_match": "20000%",
"fuzzy_prefix_length": 0,
"enable_position_increments": true,
"type": "phrase_prefix"
}
},
"sort": [
{
"followerCount": {
"order": "desc"
}
}
]
}
已邀请:

FFFrp

赞同来自:

首先看分词社区在这个字段的分词器下能否分出来两个字,如果能分出来,使用match 查询设置  minimum_should_match 为 100% 就可以了

JiangJibo - 喊我雷锋

赞同来自:

感觉不行,query_string只能查询 "text"类型的field,如果"中文区社" 分词为"中文","区社" 后,应该是能匹配到 "中文社区" 的,毕竟中文匹配上了,但是你query_string不能指定是phrase查询,你都写出来,试试看不就知道了

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

match_phrase 有个slop 参数 看能否满足要求

要回复问题请先登录注册