# ES autocomplete on cities

**URL:** <https://discuss.elastic.co/t/es-autocomplete-on-cities/153978>\
**Category:** Elasticsearch\
**Created:** [October 25, 2018, 10:59am UTC](https://discuss.elastic.co/t/es-autocomplete-on-cities/153978 "2018-10-25T10:59:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![syavel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/syavel/32/45939_2.png) [@syavel](https://discuss.elastic.co/u/syavel)\
**Post date:** [October 25, 2018, 10:59am UTC](https://discuss.elastic.co/t/es-autocomplete-on-cities/153978/1 "2018-10-25T10:59:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 22, 2018, 12:15pm UTC](https://discuss.elastic.co/t/es-autocomplete-on-cities/153978/3 "2018-11-22T12:15:10Z")

</div>

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