Reputation: 71
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"
}
}
}
Upvotes: 7
Views: 2094
Reputation: 347
I had the same issue, and what I did as a workaround was creating an index for all synonyms then searching over the synonyms index with fuzziness, to get the correct spelling of it, then let's say that you got 2 or 3 hits, now these hits are the correct spelling for your synonyms on the original index, now you can search for them without using fuzziness on the original index.
like that, you are searching with fuzziness only on synonyms.
Upvotes: 0
Reputation: 1570
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.
Upvotes: 3