Autocomplete functionality using elastic search
<p>I have an elastic search index with following documents and I want to have an autocomplete functionality over the specified fields:</p>

<p>mapping: <a href="https://gist.github.com/anonymous/0609b1d110d91dceb9a90faa76d1d5d4" rel="nofollow noreferrer">https://gist.github.com/anonymous/0609b1d110d91dceb9a90faa76d1d5d4</a></p>

<p>Usecase:</p>

<p>My query is of the form prefix type eg "sta", "star", "star w" .."start war" etc with an additional filter as tags = "science fiction". Also there queries could match other fields like description, actors(in cast field, not this is nested). I also want to know which field it matched to. </p>

<p>I investigated 2 ways for doing that but non of the methods seem to address the usecase above:</p>

<p>1) Suggester autocomplete:</p>

<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-suggesters-completion.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-suggesters-completion.html</a></p>

<p>With this it seems I have to add another field called "suggest" replicating the data which is not desirable.</p>

<p>2) using a prefix filter/query:</p>

<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-prefix-filter.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-prefix-filter.html</a></p>

<p>this gives the whole document back not the exact matching terms.</p>

<p>Is there a clean way of achieving this, please advise.</p>