Implementing autocomplete with a custom analyzer

In certain situations, you may want to create your own custom analyzer by composing character filters, tokenizers, and token filters of your choice. Please remember that most of the requirements can be fulfilled by one of the built-in analyzers with some configuration. Let us create an analyzer that can help when implementing autocomplete functionality.

To support auto-complete, we cannot rely on the Standard Analyzer or one of the pre-built analyzers in Elasticsearch. The analyzer is responsible for generating the terms at indexing time. Our analyzer should be able to generate the terms that can help with auto-completion. Let us understand this through a concrete example.

If we were to use ...

Get Learning Elastic Stack 6.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.