4

Fuzziness stopped working after me adding synonym file to the index. It seems like , it's not possible to use them at the same time. My query:

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

Mappings:

"mappings": {
"objs":{
  "properties": {
    "o":{
      "type": "string"
    },
    "loc":{
      "type":"geo_point"
    },
    "search_1":{
      "type": "string",
      "analyzer": "synonym"
    },
    "search_2":{
      "type": "string",
      "analyzer": "synonym"
    }
  }
}
Rashida
  • 41
  • 5

1 Answers1

2

I just had the same issue, and it seems like you can't mix them, somebody already opened a github issue for this: https://github.com/elastic/elasticsearch/issues/25518 The issue was closed and they updated the docs: https://github.com/elastic/elasticsearch/blob/master/docs/reference/query-dsl/match-query.asciidoc

Here is the interesting part:

Note that fuzzy matching is not applied to terms with synonyms, as under the hood these terms are expanded to a special synonym query that blends term frequencies, which does not support fuzzy expansion.

hujtomi
  • 1,540
  • 2
  • 17
  • 23