Package com.day.cq.search.suggest
Interface Suggester
public interface Suggester
A service interface for retrieving search suggestions and spell checking.
Uses a pre-built
index to look up the suggestions.
The spell check is done by leveraging the JCR full text search index.
The index can be created in various ways: by analysing most frequently used
terms in the full text index (see SearchIndexSuggestionExtractor), by
tracking actual search statistics (@see QueryTracker}, requires
configuration to synchronize with multiple publish instances) or by a custom
index creator (use SuggestionIndexManager to create indexes).
Given that the indexes won't change very often, they should be created in the background, and they can be distributed to publish instances via content packages.
-
Method Summary
Modifier and TypeMethodDescriptionString[]getSuggestions(String indexName, String term, boolean spellCheck) Deprecated.String[]getSuggestions(Session session, String indexName, String term, boolean spellCheck) Returns suggestions for a given term, which can be any partial word of at least one character.spellCheck(String term) Deprecated.use the variant with a user session argument:spellCheck(Session, String)spellCheck(Session session, String term) Uses the JCR search index to run a spellcheck for the given word.
-
Method Details
-
getSuggestions
Returns suggestions for a given term, which can be any partial word of at least one character. Depending on the given context path, different suggestion indexes can be addressed.- Parameters:
session- user session to access indexindexName- a path or name for the suggestion indexterm- partial word to look up suggestions forspellCheck- iftrue, the term will be spell checked if nothing was found and the suggestion look up will be retried with the spell check result- Returns:
- a list of search suggestions or an empty array if none could be found
-
spellCheck
Uses the JCR search index to run a spellcheck for the given word. Uses the customrep:spellcheck()Xpath function. Will return a single spell checked term ornullif the term is already correctly spelled or if no match was found.- Parameters:
session- user session to run spellcheck on repository index(es)term- the term to spell check- Returns:
- a correctly spelled term or
null
-
getSuggestions
Deprecated.use the variant with a user session argument:getSuggestions(Session, String, String, boolean)Returns suggestions for a given term, which can be any partial word of at least one character. Depending on the given context path, different suggestion indexes can be addressed.- Parameters:
indexName- a path or name for the suggestion indexterm- partial word to look up suggestions forspellCheck- iftrue, the term will be spell checked if nothing was found and the suggestion look up will be retried with the spell check result- Returns:
- a list of search suggestions or an empty array if none could be found
-
spellCheck
Deprecated.use the variant with a user session argument:spellCheck(Session, String)Uses the JCR search index to run a spellcheck for the given word. Uses the customrep:spellcheck()Xpath function. Will return a single spell checked term ornullif the term is already correctly spelled or if no match was found.- Parameters:
term- the term to spell check- Returns:
- a correctly spelled term or
null
-
getSuggestions(Session, String, String, boolean)