Package com.day.cq.search.suggest
Interface Suggester
-
public interface Suggester
A service interface for retrieving search suggestions and spell checking. Uses a pre-builtindex
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 (seeQueryTracker
, requires configuration to synchronize with multiple publish instances) or by a custom index creator (useSuggestionIndexManager
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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.lang.String[]
getSuggestions(java.lang.String indexName, java.lang.String term, boolean spellCheck)
Deprecated.use the variant with a user session argument:getSuggestions(Session, String, String, boolean)
java.lang.String[]
getSuggestions(Session session, java.lang.String indexName, java.lang.String term, boolean spellCheck)
Returns suggestions for a given term, which can be any partial word of at least one character.java.lang.String
spellCheck(java.lang.String term)
Deprecated.use the variant with a user session argument:spellCheck(Session, String)
java.lang.String
spellCheck(Session session, java.lang.String term)
Uses the JCR search index to run a spellcheck for the given word.
-
-
-
Method Detail
-
getSuggestions
java.lang.String[] getSuggestions(Session session, java.lang.String indexName, java.lang.String term, boolean spellCheck)
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
java.lang.String spellCheck(Session session, java.lang.String term)
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 ornull
if 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 java.lang.String[] getSuggestions(java.lang.String indexName, java.lang.String term, boolean spellCheck)
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 java.lang.String spellCheck(java.lang.String term)
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 ornull
if 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
-
-