Spell check Ngram for elastic Search not working with rails
Try to add fuzziness
in your multi_match
query:
{ "query": { "multi_match": { "query": "Rentaal", "fields": ["name^10", "service"], "fuzziness": "AUTO" } }}
Explanation
Kstem filter is used for reducing words to their root forms and it does not work as you expected here - it would handle corectly phrases like Renta
or Rent
, but not the misspelling you provided.
You can check how stemming works with following query:
curl -X POST \ 'http://localhost:9200/my_index/_analyze?pretty=true' \ -d '{ "analyzer" : "edge_ngram_analyzer", "text" : ["rentaal"]}'
As a result I see:
{ "tokens": [ { "token": "ren" }, { "token": "rent" }, { "token": "renta" }, { "token": "rentaa" }, { "token": "rentaal" } ]}
So typical misspelling will be handled much better with applying fuzziness.