Let's take the scenario of a site like Zomato, which helps us to search hotels. As the first step, an autocomplete suggestion needs to be employed. When the user types, the autosuggester should be able to complete or give suggestions for the hotel names the end user tries to type in. The characteristics of this feature are as follows:
It should be able to do a prefix match, that is a string such as
hot
should suggestHotel Holiday Inn
andHotel Summer Holiday Homes
.It should be able to map multiple prefixes, that is for a string
sum
, it should be able to suggestHotel Summer Holiday Homes
. Also, it should be case insensitive.It doesn't need index/type/ID information. It just needs the suggested text.
It should be super fast.
An example of autocomplete is shown in the following figure for the word chick
:
With this requirement in mind, let's see how we can implement this in Elasticsearch.
Elasticsearch offers you an out-of-the-box autocomplete feature. Remember...