Simple way to implement autocomplete functionality?


(Mihai Emil Andronache) #1

As I explained here: https://github.com/elastic/elasticsearch/issues/22137
I would like to implement a simple autocomplete; user starts typing, the index is consulted and similar keywords are returned. E.g. auth -> authorization, authentication.

I found the Completion Suggester way: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html

However, that seems too complicated, I'm thinking there must be some other way.

And also, I don't seem to understand the completion suggester properly. I have to do that mapping and then I have to provide suggestions?! How does that work? I see the "Index" section of the article where apparently I have to provide options... for what words - how could any setting of mine ever cover all that a user could type? I don't get it.

On the other hand, word correction which is clearly a more difficult thing to implement, can be done out of the box with a simple Suggester query. It seems ridiculous that autocomplete cannot come out of the box as well...

Any help would be appreciated.

Many thanks,
Mihai


(Patlola) #2

please read this book elasticsearch guide
it has all kinds of information regarding dealing with ES in detail.

https://www.elastic.co/guide/en/elasticsearch/guide/current/_query_time_search_as_you_type.html


(Mihai Emil Andronache) #3

Do you happen to know how to use the Completion Suggester in a real scenario?
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-suggesters-completion.html

I read the documentation but it makes no sense to me.
Maybe it works for clearly sturctured data, like music albums. You index the albums and then you go one-by-one and index suggestion possibilities ... !?

How does that work for full texts, entire documents? How do I automate the process of indexing suggestions? It surely cannot be that I have to go and manually index suggestions that I think the user might type...

Br,
Mihai


(Patlola) #4

you need to write scripts to automate the indexing.
you need to index all the data which you have to be able to searchable for the user.
please take some ES course for more clarification.


(Mihai Emil Andronache) #5

So after I index a document, is it my job to parse the contents of a field, split it in words/tokens and implement logic to specify autocompletion options for each word and index them? Again, I don't think it can be this way: ES has the power to auto-correct words, but it doesn't have the power to auto-complete them?!

I would expect ES to be able to do that once I indexed the document (probably I would have to specify some analyzier or whatever)...


(Patlola) #6

NO, ES will do it


(system) #7

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