AutoComplete Feature in Elastic Search

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

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 ?

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

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?

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