在Elasticsearch中的TEXT字段的情况下,有什么方法可以进行完全匹配? [英] Is there any way to do exact match in case of TEXT field in Elasticsearch?

查看:51
本文介绍了在Elasticsearch中的TEXT字段的情况下,有什么方法可以进行完全匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将匹配查询作为"a b c"与"operator":"and"传递,而且在resultSet中得到了"a b c d"(按预期方式).有什么方法可以消除"a b c d"?

I am passing match query as "a b c" with "operator":"and" but also, getting "a b c d" in the resultSet (as Expected). Is there any way to eliminate "a b c d"?

推荐答案

要进行完全匹配,您可以在查询中使用"match_phrase"代替"match",并消除"abcd"类型的字符串即可在"must_not"块中.例如:

To do an exact match you can use "match_phrase" instead of "match" in your query and to eliminate the "a b c d" type string you can simply place it inside a "must_not" block. example:

 {
  "query": {
    "bool": {
      "must_not": [
      {
        "match_phrase": {
          "field": "value"
        }
      }
     ]
    }
  }
}

这篇关于在Elasticsearch中的TEXT字段的情况下,有什么方法可以进行完全匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆