Package org.apache.solr.spelling
Class AbstractLuceneSpellChecker
- java.lang.Object
 - 
- org.apache.solr.spelling.SolrSpellChecker
 - 
- org.apache.solr.spelling.AbstractLuceneSpellChecker
 
 
 
- 
- Direct Known Subclasses:
 FileBasedSpellChecker,IndexBasedSpellChecker
public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker
Abstract base class for all Lucene-based spell checking implementations.Refer to https://solr.apache.org/guide/solr/latest/query-guide/spell-checking.html for more details.
- Since:
 - solr 1.3
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected floataccuracystatic StringACCURACYstatic StringCOMPARATOR_CLASSstatic intDEFAULT_SUGGESTION_COUNTprotected org.apache.lucene.search.spell.Dictionarydictionarystatic StringFIELDstatic StringFREQ_COMPprotected org.apache.lucene.store.Directoryindexstatic StringINDEX_DIRprotected StringindexDirstatic StringLOCATIONstatic StringSCORE_COMPprotected org.apache.lucene.search.spell.StringDistancesdprotected StringsourceLocationprotected org.apache.lucene.search.spell.SpellCheckerspellCheckerstatic StringSPELLCHECKER_ARG_NAMEstatic StringSTRING_DISTANCE- 
Fields inherited from class org.apache.solr.spelling.SolrSpellChecker
analyzer, DEFAULT_DICTIONARY_NAME, DICTIONARY_NAME, field, FIELD_TYPE, fieldTypeName, name 
 - 
 
- 
Constructor Summary
Constructors Constructor Description AbstractLuceneSpellChecker() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.lucene.index.IndexReaderdetermineReader(org.apache.lucene.index.IndexReader reader)floatgetAccuracy()Get the value ofSpellingParams.SPELLCHECK_ACCURACYif supported.StringgetField()StringgetFieldTypeName()StringgetIndexDir()StringgetSourceLocation()org.apache.lucene.search.spell.SpellCheckergetSpellChecker()org.apache.lucene.search.spell.StringDistancegetStringDistance()Get the distance implementation used by this spellchecker, or NULL if not applicable.SpellingResultgetSuggestions(SpellingOptions options)Get suggestions for the given query.Stringinit(org.apache.solr.common.util.NamedList<?> config, SolrCore core)protected voidinitIndex()voidreload(SolrCore core, SolrIndexSearcher searcher)Reloads the index.- 
Methods inherited from class org.apache.solr.spelling.SolrSpellChecker
build, getDictionaryName, getQueryAnalyzer, isSuggestionsMayOverlap, mergeSuggestions, modifyRequest 
 - 
 
 - 
 
- 
- 
Field Detail
- 
SPELLCHECKER_ARG_NAME
public static final String SPELLCHECKER_ARG_NAME
- See Also:
 - Constant Field Values
 
 
- 
LOCATION
public static final String LOCATION
- See Also:
 - Constant Field Values
 
 
- 
INDEX_DIR
public static final String INDEX_DIR
- See Also:
 - Constant Field Values
 
 
- 
ACCURACY
public static final String ACCURACY
- See Also:
 - Constant Field Values
 
 
- 
STRING_DISTANCE
public static final String STRING_DISTANCE
- See Also:
 - Constant Field Values
 
 
- 
COMPARATOR_CLASS
public static final String COMPARATOR_CLASS
- See Also:
 - Constant Field Values
 
 
- 
SCORE_COMP
public static final String SCORE_COMP
- See Also:
 - Constant Field Values
 
 
- 
FREQ_COMP
public static final String FREQ_COMP
- See Also:
 - Constant Field Values
 
 
- 
spellChecker
protected org.apache.lucene.search.spell.SpellChecker spellChecker
 
- 
sourceLocation
protected String sourceLocation
 
- 
index
protected org.apache.lucene.store.Directory index
 
- 
dictionary
protected org.apache.lucene.search.spell.Dictionary dictionary
 
- 
DEFAULT_SUGGESTION_COUNT
public static final int DEFAULT_SUGGESTION_COUNT
- See Also:
 - Constant Field Values
 
 
- 
indexDir
protected String indexDir
 
- 
accuracy
protected float accuracy
 
- 
FIELD
public static final String FIELD
- See Also:
 - Constant Field Values
 
 
- 
sd
protected org.apache.lucene.search.spell.StringDistance sd
 
 - 
 
- 
Method Detail
- 
init
public String init(org.apache.solr.common.util.NamedList<?> config, SolrCore core)
- Overrides:
 initin classSolrSpellChecker
 
- 
getSuggestions
public SpellingResult getSuggestions(SpellingOptions options) throws IOException
Description copied from class:SolrSpellCheckerGet suggestions for the given query. Tokenizes the query using a field appropriate Analyzer. TheSpellingResult.getSuggestions()suggestions must be ordered by best suggestion first.- Specified by:
 getSuggestionsin classSolrSpellChecker- Parameters:
 options- TheSpellingOptionsto use- Returns:
 - The 
SpellingResultsuggestions - Throws:
 IOException- if there is an error producing suggestions
 
- 
determineReader
protected org.apache.lucene.index.IndexReader determineReader(org.apache.lucene.index.IndexReader reader)
 
- 
reload
public void reload(SolrCore core, SolrIndexSearcher searcher) throws IOException
Description copied from class:SolrSpellCheckerReloads the index. Useful if an external process is responsible for building the spell checker.- Specified by:
 reloadin classSolrSpellChecker- Throws:
 IOException- If there is a low-level I/O error.
 
- 
initIndex
protected void initIndex() throws IOException- Throws:
 IOException- If there is a low-level I/O error.
 
- 
getAccuracy
public float getAccuracy()
Description copied from class:SolrSpellCheckerGet the value ofSpellingParams.SPELLCHECK_ACCURACYif supported. Otherwise throws UnsupportedOperationException.- Overrides:
 getAccuracyin classSolrSpellChecker
 
- 
getField
public String getField()
 
- 
getFieldTypeName
public String getFieldTypeName()
 
- 
getIndexDir
public String getIndexDir()
 
- 
getSourceLocation
public String getSourceLocation()
 
- 
getStringDistance
public org.apache.lucene.search.spell.StringDistance getStringDistance()
Description copied from class:SolrSpellCheckerGet the distance implementation used by this spellchecker, or NULL if not applicable.- Overrides:
 getStringDistancein classSolrSpellChecker
 
- 
getSpellChecker
public org.apache.lucene.search.spell.SpellChecker getSpellChecker()
 
 - 
 
 -