如下代码片段所示,有没有办法可以做到,如果我查“123456“这个term存在就直接返回,而不去查下面的两个match_phrase,若“123456“这个term的结果不存在,则用match_phrase去查123和456?
{
"query": {
"bool":{
"filter":{
"bool":{
"should":
[
{"term" : { "text" :"123456" }},
{
"bool":{
"must":[
{"match_phrase" : { "text" :"123" }},
{"match_phrase" : { "text" :"456" }}
]
}
}
]
}
}
}
}
}
1 个回复
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自:
2 text确认能分词为 123 456,用的什么分词,analyzer api验证下