Grouping similar results in aggs search

Hi community,

I am hoping someone can help. I have ES 7.5.2 running and indexed a whole bunch of documents. When a user performs a search I store this in another index so I can later recall the previous searches. This is also working well however when I perform a lookup of previous searches (as a user types/auto suggest) I am getting some messy information. I know why but I am wondering if there's a way to stop it.

The information I get are duplicate results but for incomplete words.

For example:
User searched for: What is ri
User searched for: What is risk
User searched for: What is risky

Now if a user starts typing: "What is r" I would like only 1 result to appear which should be "What is risky" as that is the most complete query. I know ES stored all 3 queries as different requests but is it possible to show the best option only?

My aggs is:

"aggs": {
  "suggester": {
    "terms": {
      "field": "title_na"
    }
  }
}

Thoughts?

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