使用match_phrase查询语句如下,如何保证查出的结果中先出现张三后出现李四?并且“三张”“四李”的情况不要匹配,使用的分词器汉字是每个字都进行了分词。
curl -XGET "http://127.0.0.1:9200/blog/_se ... ot%3B -H 'Content-Type: application/json' -d '
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"message": "张三"
"slop":5
}
},
{
"match_phrase": {
"message": "李四"
"slop":5
}
}
]
}
}
}'
curl -XGET "http://127.0.0.1:9200/blog/_se ... ot%3B -H 'Content-Type: application/json' -d '
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"message": "张三"
"slop":5
}
},
{
"match_phrase": {
"message": "李四"
"slop":5
}
}
]
}
}
}'
3 个回复
fanmo3yuan
赞同来自:
2. “三张”不要匹配,首先把slop去掉,另外也可以使用ngram去做分词
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自:
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自: