Hi,
I'm trying to create an autocomplete on my own cities base.
I've this fields for my documents:
{
"ac": "london"
"population": 7556900,
"state": England,
...
...
}
My mapping for the ac field is
"ac" : {
"type" : "completion",
"analyzer" : "autocomplete",
"search_analyzer" : "autocomplete"
}
with the index
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter",
"asciifolding"
]
},
"autocomplete2": {
"type": "custom",
"tokenizer": "comma",
"filter": [
"lowercase",
"autocomplete_filter",
"asciifolding"
]
}
},
"tokenizer": {
"comma": {
"type": "pattern",
"pattern": ","
}
}
}
With the request {
//"_source": ["city", "population", "ac"],
"suggest" : {
"acsuggest":{
"text" : "london",
"completion" : {
"field" : "ac",
"size":10
}
}
}
}
All is working.
My question is, I have a city with the name "saint-andre-de cubzac", I would like when the search text is "cubzac" I could Have the city "saint-andre-de cubzac", it's not the case for the moment.
ideally, I would also like bigger city is sorting in first with the population field.
I've tried ngram, multisearch and other thing, but it doesn't work.
Thanks for your help