How to make suggestions taking into account a few document fields?

Hi all!

I'm trying to master Elasticsearch and there is one issue I have run into.

My documents have fields first_name, last_name, and country. And seems the search is working as I'm expecting with a multi_match query.

But now I want to add a suggestion feature and seems I can run it for each field separately with no problems. But this is not catering to my needs because it will generate a lot of possible combinations for each field which I will need to glue together. Most likely it will be confusing and not relevant.

What I want - is to have one combined field for each document with user county, first name, and last name. So I can perform my lookup on it and make my relevant suggestions.

I have tried to use "script" for this case. But seems this is not the right way or I'm doing something wrong. Can you please share with me some insights on how that feature can be implemented?

I don't know how you solved it but if you're talking about creating a "suggestion" like "autocomplete", I can tell you how I solved it.

I used "copy_to" to copy terms from several fields to a single one. In this new field I used a shingle filter (min=2 and max=4).

Then I created a query prefix to finish the autocomplete.

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