At UI I need to show the autocomplete suggestions which gives me the terms containing the searched term. e.g. if I search per
I may get suggestions as Peru
, Perry
, Casper
, Naperville
, Cooperstown
etc.
The search box is to search/filter on a filed which is being used/shown as the terms aggregation for cities. This field type is array, so one document can have multiple cities. The auto-suggestions should only have the cities from available/resulted documents.
I am aware to use the filter Feature of terms aggregation with the proper regex. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values_4
But I am looking for a better solution available in elasticsearch which can provide me the fastest results.