# Autocomplete over multiple fields while maintaining context

**URL:** https://discuss.elastic.co/t/autocomplete-over-multiple-fields-while-maintaining-context/51955
**Category:** Elasticsearch
**Created:** [June 6, 2016, 2:32pm UTC](https://discuss.elastic.co/t/autocomplete-over-multiple-fields-while-maintaining-context/51955 "2016-06-06T14:32:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![coreation](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/coreation/32/10165_2.png) [@coreation](https://discuss.elastic.co/u/coreation)
#### Post date: [June 6, 2016, 2:32pm UTC](https://discuss.elastic.co/t/autocomplete-over-multiple-fields-while-maintaining-context/51955/1 "2016-06-06T14:32:34Z")

</div>

Hi all!

So my challenge is the following. I need to autocomplete an input that is based on 3 fields (tags, category, industry).  
So the autocompletion should return values from those 3 fields, however, the response of an autocomplete request should also have the field that it matched on so I don't loose the context of the autocomplete.

Example:

tags: foobar, foo, bar  
category: foo,  
industry:bar

If I type in "fo" then I want to have something that resembles the following as an autocomplete response:

"tags": foobar, foo  
"category": foo

As far as my entire afternoon search went, I've found only partial solutions such as autocompleting over multiple fields by putting them into an \_all field which is then analyzed, but that solutions looses its context.

The context suggester looks promising but I haven't gotten it to work just yet. To be fair i( might just be me ) that documentation page lacks a serious example :(.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 10:45pm UTC](https://discuss.elastic.co/t/autocomplete-over-multiple-fields-while-maintaining-context/51955/2 "2017-07-05T22:45:55Z")

</div>


