I want to autocomplete service via Elasticsearch.I need a "did you mean" of google style. I researched very much how can I to do. I was find a fuzzy search. When I entered to "Alman", I want to Almanya only. But I received Umman too. How can I getting only "almanya"?
{
"highlight": {"fields": [{"CountryName": {"type": "plain"}}]},
"query": {
"bool": {
"should": [
{
"match": {
"CountryName": {
"boost": 1,
"fuzziness": 5,
"query": "Alman"
}
}
},
{
"match": {
"CountryNameTurkish": {
"boost": 1,
"fuzziness": 5,
"query": "Alman"
}
}
}
]
}
}
}
Response
{
"hits": {
"total": 2,
"max_score": 1.9666269,
"hits": [
{
"_index": "country_codes_v1",
"_type": "kafka_connect",
"_id": "OM",
"_score": 1.9666269,
"_source": {
"CountryCode": "OM",
"CountryName": "Oman",
"Continent": "Middle East",
"CapitalCityCode": "MCT",
"Duplicate": 0,
"CountrySlug": "om-oman",
"CountryNameTurkish": "Umman"
}
},
{
"_index": "country_codes_v1",
"_type": "kafka_connect",
"_id": "DE",
"_score": 1.6418773,
"_source": {
"CountryCode": "DE",
"CountryName": "Germany",
"Continent": "Europe",
"CapitalCityCode": "BER",
"Duplicate": 0,
"CountrySlug": "de-germany",
"CountryNameTurkish": "Almanya"
}
}
]
}
}