How can I get the desired output at query time for my edge-ngram autocomplete, given my mappings?
Desired Output
"Fish Lake, New Zealand"
"Fife Rock, New Zealand"
"Fish Rock, New Zealand"
>"Finger Rocks, New Zealand"<
>"Lake Fiddle, New Zealand"<
Actual Output
"Fish Lake, New Zealand"
"Fife Rock, New Zealand"
"Fish Rock, New Zealand"
>"Lake Fiddle, New Zealand"<
>"Finger Rocks, New Zealand"<
Search Query
POST /300_localities_nz/_search?pretty
{
"_source": ["search_name"],
"size": 5,
"query": {
"match": {
"search_name.autocomplete": {
"query": "Fi",
"operator": "and",
"fuzziness": "Auto"
}
}
}
}
Settings
{
"300_localities_nz" : {
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"english_stopwords" : {
"type" : "stop",
"stopwords" : "_english_"
}
},
"analyzer" : {
"autocomplete_index" : {
"filter" : [
"lowercase",
"english_stopwords"
],
"type" : "custom",
"tokenizer" : "autocomplete_index"
},
"autocomplete_search" : {
"tokenizer" : "lowercase"
}
},
"tokenizer" : {
"autocomplete_index" : {
"token_chars" : [
"digit",
"letter"
],
"min_gram" : "2",
"type" : "edge_ngram",
"max_gram" : "10"
}
}
}
}
}
}
}
Mappings
{
"300_localities_nz" : {
"mappings" : {
"properties" : {
"search_name" : {
"type" : "text",
"fields" : {
"autocomplete" : {
"type" : "text",
"analyzer" : "autocomplete_index",
"search_analyzer" : "autocomplete_search"
},
"exact" : {
"type" : "keyword"
}
}
}
}
}
}
}