Elasticsearch Non Analyzed Fields Regex aggregation

Hi Everyone

I am implementing one feature which includes city names (Example: "New York", "San Francisco"). I need to find document count at run time when user is typing the word. More like auto complete with counts.

Input: "Ne"
Output: "New York - 100 documents"

For this usecase in mind:
I created two fields namely cities(type: string, standard analyzer) and cities_non_analyzed (type: string, non analyzed).

But I am not able to apply it on non analyzed cities field using include in aggregations to get counts for the words that are matched in analyzed field.

Any pointer will be of good help

Sri Harsha


I got a solution for this.

I am not able to delete this quesiton !! Can someone with appropriate rights delete the question.

Sri Harsha

Why not share your solution so others can learn as well?

Hi Harsha,

I am also currently facing the same issue. It would be nice if you could share your solution.