【发布时间】:2021-03-22 12:32:49
【问题描述】:
我在 elasticsearch 中索引了以下 2 个条目:
united states
united states minor outlying islands
我想模糊匹配距离为 1,因此如果我发送以下查询词,我只想匹配 united states:
united tsates
unitedstates
united sates
我尝试了其他问题(here 和 here)中建议的 span_near 方法,但这仍然与 united states 和 united states minor outlying islands 匹配。
如何仅将united states 与上述术语列表匹配?
第一次尝试:
{
"query":{
"bool":{
"must":{
"match":{
"country_name":{
"query":"united tsates",
"fuzziness":1,
"operator": "and"
}
}
}
}
}
}
尝试span_near:
{
"query":{
"span_near":{
"clauses":[
{
"span_multi":{
"match":{
"fuzzy":{
"country_name":{
"fuzziness":"1",
"value":"united"
}
}
}
}
},
{
"span_multi":{
"match":{
"fuzzy":{
"country_name":{
"fuzziness":"1",
"value":"tsates"
}
}
}
}
}
],
"slop":0,
"in_order":"true"
}
}
}
【问题讨论】:
标签: elasticsearch