如何使用同义词模糊搜索?

Ras*_*ida 5 fuzzy elasticsearch

在我将同义词文件添加到索引后,模糊性停止工作。看来,不可能同时使用它们。我的查询:

 "query": {
        "dis_max": {
            "queries": [{ 
                 "multi_match": {
                 "query": $('#searchterm').val(),
                 "fields": ["search_1"],
                 "fuzziness": "AUTO", 
                 "operator":  "and",
                 "max_expansions": 1
             }},
                { "match": { "search_2": $('#searchterm').val() }}
            ]
        }
    }
Run Code Online (Sandbox Code Playgroud)

映射:

"mappings": {
"objs":{
  "properties": {
    "o":{
      "type": "string"
    },
    "loc":{
      "type":"geo_point"
    },
    "search_1":{
      "type": "string",
      "analyzer": "synonym"
    },
    "search_2":{
      "type": "string",
      "analyzer": "synonym"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

huj*_*omi 3

我刚刚遇到了同样的问题,似乎你不能混合它们,有人已经为此打开了一个 github 问题: https: //github.com/elastic/elasticsearch/issues/25518该问题已关闭,他们更新了文档: https://github.com/elastic/elasticsearch/blob/master/docs/reference/query-dsl/match-query.asciidoc

这是有趣的部分:

请注意,模糊匹配不适用于具有同义词的术语,因为这些术语在底层会扩展为混合术语频率的特殊同义词查询,而该查询不支持模糊扩展。