Book Image

ElasticSearch Blueprints

Book Image

ElasticSearch Blueprints

Overview of this book

Table of Contents (15 chapters)
Elasticsearch Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Autocomplete in Elasticsearch


Autocomplete provides suggestions while you type in a field. This feature is immensely helpful during search operations as it saves a user's time and also enables them to see various other related options in a single stretch. A prefix query is one way to implement this. A prefix query matches documents that have fields containing terms with the same prefix.

It is natural for you to think why we don't use a prefix query to solve the autocomplete problem or rather, what is the requirement for a separate API and module to implement autocomplete. The primary reason here is performance. The ideal data structure for autocomplete would be finite state automata (FST), which is explained in the following section, but then we are not storing tokens in FST in Lucene. Hence, it's only reasonable to maintain and have a separate module for autocomplete and to maintain a different data structure to store autocomplete-related data. It has to be noted that data related to autocomplete...