具有模糊性的Elasticsearch通配符查询字符串

问题描述 投票:12回答:1

我们有一个项目索引,我正在尝试对项目名称进行模糊通配符处理。查询

{
  "from": 0,
  "size": 10,
  "query": {
    "bool": {
      "must": {
        "query_string": {
          "fields": [
            "name.suggest"
          ],
          "query": "avacado*",
          "fuzziness": 0.7
        }
      }
    }
  }
}

索引中的字段和正在使用的分析器“

suggest_analyzer":{
    "type": "custom",
    "tokenizer": "standard",
    "filter": ["standard", "lowercase", "shingle", "punctuation"]
  }


"punctuation" : {
    "type" : "word_delimiter",
    "preserve_original": "true"
  }



"name": {
    "fields": {
      "name": {
        "type": "string",
        "analyzer": "stem"
      },
      "suggest":{ 
        "type": "string", 
        "analyzer": "suggest_analyzer"
      },
      "untouched": {
        "include_in_all": false,
        "index": "not_analyzed",
        "index_options": "docs",
        "omit_norms": true,
        "type": "string"
      },
      "untouched_lowercase": {
        "type": "string", 
        "index_analyzer": "lowercase",
        "search_analyzer": "lowercase"
      }
    },
    "type": "multi_field"
  },

问题是这个

名称为“鳄梨测试”的项目将与以下项目匹配

  • 鳄梨*
  • avo *
  • avacado

但无法匹配

  • avacado *
  • ava *
  • ava〜2

我似乎无法对通配符进行模糊运算,这似乎是模糊运算或通配符起作用,但不能组合使用。

ES版本是1.3.1

请注意,我的查询已简化,我们正在进行其他过滤,但我将其归结为仅查询,以消除结果中的任何歧义。我尝试使用建议功能,但它们不允许我们需要的过滤级别。

还有其他方法来处理建议/预先输入样式搜索时会模糊不清以捕获拼写错误吗?

search elasticsearch wildcard
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.