Achieve autocomplete with fuzziness

I am trying to achieve autocomplete with a level of fuzziness. I tried different settings with the help of documentation.

My configuration:
PUT http://localhost:9200/my_index/ { "settings": { "analysis": { "analyzer": { "folding": { "tokenizer": "standard", "filter": [ "lowercase", "asciifolding", "umlaut", "ngram_filter" ] }, "folding_search": { "tokenizer": "standard", "filter": [ "lowercase", "asciifolding", "umlaut" ] } }, "filter": { "umlaut": { "type": "snowball", "language": "German2" }, "ngram_filter": { "type": "edge_ngram", "min_gram": 1, "max_gram": 25 } } } }, "mappings": { "_doc": { "properties": { "full_name": { "type": "text", "analyzer": "standard", "fields": { "folded": { "type": "text", "analyzer": "folding", "search_analyzer": "folding_search" } } } } } } }

I added data using the following command:
`
curl -X POST "localhost:9200/my_index/_doc/_bulk" -H 'Content-Type: application/json' -d'

{ "index": { "_id": "1" } }

{ "full_name": ["brown fox"] }

{ "index": { "_id": "2" } }

{ "full_name": ["fox"] }

{ "index": { "_id": "3" } }

{ "full_name": ["quick brown fox"] }

{ "index": { "_id": "4" } }

{ "full_name": ["brown brown brown"] }

{ "index": { "_id": "5" } }

{ "full_name": ["brown color"] }

{ "index": { "_id": "6" } }

{ "full_name": ["fox is clever"] }

{ "index": { "_id": "8" } }

{ "full_name": ["quick jump"] }

{ "index": { "_id": "9" } }

{ "full_name": ["brown table"] }

{ "index": { "_id": "10" } }

{ "full_name": ["brown shirt"] }

{ "index": { "_id": "11" } }

{ "full_name": ["blue shirt"] }

{ "index": { "_id": "12" } }

{ "full_name": ["brown foxi"] }

{ "index": { "_id": "13" } }

{ "full_name": ["fox"] }

{ "index": { "_id": "14" } }

{ "full_name": ["orange"] }

{ "index": { "_id": "15" } }

{ "full_name": ["grapes"] }

{ "index": { "_id": "16" } }

{ "full_name": ["fish"] }

{ "index": { "_id": "17" } }

{ "full_name": ["brown fish"] }

{ "index": { "_id": "18" } }

'
`

My query is:
POST http://localhost:9200/my_index/_search { "query": { "multi_match": { "query": "brown fox", "fields": ["full_name", "full_name.folded"], "fuzziness": 1 } } }

When I searched for "brown fox", what I expected the result to be is "brown fox" and "brown foxi" at the top (with high score), but what I got is different:
"brown foxi"
"brown brown brown"
"quick brown fox"
"brown fox"

How can I resolve this? Please help.

Thanks.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.