HOW TO IMPLEMENT AUTOCOMPLETION AND SEARCH SUGGESTION IN AEM THROUGH LUCENE | PREDICTIVE SEARCH IN AEM | AEM SEARCH SUGGESTIONS
This tutorial explain the approach to implement autocompletion and search suggestion in AEM through Lucene.
When you start typing something in search form most of the applications helps you by suggesting the data matching to your search term.
The purpose of autocomplete is to resolve a partial query , i.e., to search within a controlled vocabulary for items matching a given character string.
Starting from AEM 6.1 the feature of suggestion is available through the suggest module of Lucene. Prior to AEM 6.1, all the possible combination of the words needs to be indexed to support the autocompletion.
The Lucene Suggest module provides a dedicated and optimized data structure allows the engine to give autocompletion and suggestion feature without indexing all the possible combination of a word.
There is a specific analyzer (AnalyzingInfixSuggester) used that loads the completion values from the indexed data and then build the optimized structure in memory for a fast lookup.
In order to implements the autosuggestion, feature you need to define an index of type Lucene and for each property X of nodes that you are indexing you can add a specific property useInSuggest to tell to the engine to use X for suggesting query to the user.
Refer the following URL for details on enabling custom index - https://www.albinsblog.com/2020/04/oak-lucene-index-improve-query-in-aem-configure-lucene-index.html