elasticsearch - ElasticSearch匹配查询数字模糊性

标签 elasticsearch

如果我搜索带有数字的 token ,则模糊不正确。

Dokument:
"Nice Photo S61"

给我查询结果

“不错”

但是我不会马上使用

“S6”

我没有结果

这是我的查询
GET /index1/_search
{
    "query": {
        "match" : {
         "url1" : {
             "query" : "s6",
             "fuzziness": "auto",
             "prefix_length": "3",
              "max_expansions": 6,
              "operator":  "and"
        }
    }
  }
}

这是我的索引设置:
  PUT /index1/_settings
{
  "settings": {
    "analysis": {
      "analyzer": {
        "product_analyzer": {
          "type": "custom",

          "tokenizer": "punctuation", 
          "filter": [
            "lowercase" 
          ]
        }
      },
      "tokenizer": {
        "punctuation": { 
          "type": "pattern",
          "pattern": "[-_.:~ ]"
        }
      }
      }
  },
  "mappings" : {
    "index1" : {
      "properties" : {
        "url":{
        "type" :"text",
        "analyzer" : "product_analyzer"
        }
        }
      }
    }
  }

最佳答案

这与数字无关。
fuzziness设置为auto时,意味着根据您的术语自动生成编辑距离。

AUTO

Generates an edit distance based on the length of the term. Low and high distance arguments may be optionally provided AUTO:[low],[high]. If not specified, the default values are 3 and 6, equivalent to AUTO:3,6 that make for lengths:

0..2 Must match exactly

3..5 One edit allowed

>5 Two edits allowed AUTO should generally be the preferred value for fuzziness.





prefix_length

The number of initial characters which will not be “fuzzified”. This helps to reduce the number of terms which must be examined. Defaults to 0.



因此,您可以将查询更改为此:
{
    "query": {
        "match" : {
         "url1" : {
             "query" : "S6",
             "fuzziness": "1",
             "prefix_length": "0",
              "max_expansions": 6,
              "operator":  "and"
        }
    }
  }
}

引用:
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html

关于elasticsearch - ElasticSearch匹配查询数字模糊性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55273145/

相关文章:

elasticsearch - ElasticSearch突出显示内部字段

many-to-many - Elasticsearch 中的多对多关系

elasticsearch - Elastalert 在一个文件中简化了多个规则

windows - 将数据从Docker容器持久保存到主机

python - Haystack 使用的 ElasticSearch 索引因未知原因损坏

elasticsearch - 具有混合嵌套/非嵌套过滤器的嵌套对象聚合项

ElasticSearch按数组字段过滤不包含某些值

ElasticSearch REST - 不使用类插入 JSON 字符串

search - 如何在elasticsearch中配置synonyms_path

java - Elasticsearch 5 卡住从磁盘读取