# AutoComplete Feature in Elastic Search

**URL:** https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449
**Category:** Elasticsearch
**Created:** [August 2, 2019, 5:50am UTC](https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449 "2019-08-02T05:50:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Adi\_Ti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi_ti/32/51488_2.png) [@Adi\_Ti](https://discuss.elastic.co/u/Adi_Ti)
#### Post date: [August 2, 2019, 5:50am UTC](https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449/1 "2019-08-02T05:50:29Z")

</div>

want to implement autocomplete with elasticsearch and I'm unable to do it. I want something like this question here. I tried the suggested answers but in vain. I want to have something like the following :

I have used complete suggester to handle such scenarios .Since order of search is important .

A simple example would be having these documents indexed using standard analyzer:

A :Source B :Destination

```auto
1. Bus from A to B 
2. Morning Bus from A to B 
3. Bus Fare from B to A
4. Cheapest Bus Fare from B via C to A

```

I could query for "A" and this would return me all documents, including the third one.I want to retrieve only documents 1 and 2 .If I query "B" only documents 3 and documents 4 should return.Slop is not specific to 1 or 2 it can be anything .

Please suggest the index settings properties for this and share the code

What if I wanted to only retrieve the documents which have the terms in this specific order? Can I form a query that would do that for me?

Considering it is possible for phrases by simply quoting the text: "Bus A" (retrieve 1st and 2nd docs) it feels to me like there should be a way of preserving the order for multiple terms that aren't adjacent. I have used complete suggester .But it doesnot seem to solve all the use cases . Please suggest ?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 2, 2019, 8:12am UTC](https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449/2 "2019-08-02T08:12:57Z")

</div>

Hey,

Maybe this is less of a suggest/auto-complete question but more of a data modeling question. If you would only index the source cities in a dedicated field and only query that, this would be much simpler, than trying to extract this information from a regular text field.

Would that be an option?

--Alex

---

<div class="post-metadata">

### Author: ![Adi\_Ti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi_ti/32/51488_2.png) [@Adi\_Ti](https://discuss.elastic.co/u/Adi_Ti)
#### Post date: [August 2, 2019, 10:20am UTC](https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449/4 "2019-08-02T10:20:51Z")

</div>

How will I handle the autosuggest in case?I have show the autosuggest to the user .  
If user types Bus from A...  
My suggestion should be:  
Bus from A to B  
Bus from A to C  
Bus from A to D  
Not this Bus from B to A.  
Although I have pre-populated Bus from B to A in the elastic search.How to handle such scenario?

If user types  
Morning Bus from A ..  
My Suggestion should be  
Morning Bus from A to B  
Morning Bus from A to C  
Morning Bus from A to D

I have populated Bus from A to B,Bus from A to C and Bus from A to D in elastic search.How can I handle scenario 2?

---

<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: [August 30, 2019, 10:20am UTC](https://discuss.elastic.co/t/autocomplete-feature-in-elastic-search/193449/5 "2019-08-30T10:20:54Z")

</div>

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