ElasticSearch autocomplete/suggest by token

I want to create search suggestions based on the tokens (and not full documents) that are present in my index.

For example:
I have a simple index for movies in which I have these two documents:

  1. {"name":"Captain America"}
  2. {"name":"American Made"}

If I type "ame" then I should get two suggestions (as tokens)

  1. america
  2. american

Similarly if I type "cap" then I should get "captain" and not "Captain America"

I am having exact same problem as this post:
Elasticsearch autocomplete- / suggest by token

I have gone through all types of suggesters and seems like they are focused on returning the whole documents rather than the tokens.

Apache Solr serves this requirement through its autosuggest functionality:

For example, if I type kni then Solr would return knives, knife and knit as suggestions (based on the tokens coming from the indexed documents)


One of the probable solution is mentioned in this StackOverflow thread:
Elasticsearch autocomplete or autosuggest by token - Stack Overflow

But it relies on explicitly adding all the suggestions in every document. This seems to be a tedious approach.

Please let me know if this can be achieved somehow in a better way.

Thanks in advance.

1 Like

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