能否在multi_match查询中仅对一个字段使用模糊性? [英] Is it possible to use fuzziness for only one field in a multi_match query?

查看:44
本文介绍了能否在multi_match查询中仅对一个字段使用模糊性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Elasticsearch中使用以下multi_match查询,并且想知道我是否只能对"friendly_name field"使用模糊性.我尝试了不同的方法,但似乎没有用.我也想知道是否可以使用分析仪获得与模糊性相似的结果:

I am using the following multi_match query in Elasticsearch and I am wondering if I can use fuzziness only for "friendly_name field". I have tried different things but doesn't seem to work. I am also wondering if it possible to use an analyzer to get a similar result as the fuzziness does:

    "query": { 
  "multi_match": {
         "query": "input query",            
         "fields": ["code_short", "code_word","friendly_name"],
         "minimum_should_match": "2"
  }   }, "_source": ["code", "friendly_name"]

任何帮助将不胜感激.谢谢.

Any help would be appreciated. Thanks.

推荐答案

如果只需要查询一个字段,则不需要多重匹配

If you only need query on one field , you don't need multi match

"match": {
        "name": {
            "query":     "your query",
            "fuzziness": "1.5",
            "prefix_length": 0,
            "max_expansions": 100,
            "minimum_should_match": "80%"
        }
    }

我不认为您可以完全取代模糊性,但是您有2种选择可能适合您.ngram过滤器或词干过滤器.

I don't believe that you can fully replace fuzziness, but you have 2 options to explore that might work for you. ngram filter or stemmer filter.

=======好吧,对我来说,你的意图不是很清楚.但是您可以通过以下方式进行查询:

====== Well it wasn't very clear to me what you've intended. But you can do your query that way:

"query": {
      "bool": {
        "should": [
          {
            "match": {
              "friendly_name": {
                "query": "text",
                "fuzziness": "1.5",
                "prefix_length": 0,
                "max_expansions": 100
              }
            }
          },
          {
            "match": {
              "code_word": {
                "query": "text"
              }
            }
          },
          {
            "match": {
              "code_short": {
                "query": "text"
              }
            }
          }
        ],
        "minimum_should_match" : 2
      }

}

这篇关于能否在multi_match查询中仅对一个字段使用模糊性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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