Package org.apache.solr.spelling.suggest
Class Suggester
- java.lang.Object
-
- org.apache.solr.spelling.SolrSpellChecker
-
- org.apache.solr.spelling.suggest.Suggester
-
public class Suggester extends SolrSpellChecker
-
-
Field Summary
Fields Modifier and Type Field Description protected SolrCore
core
protected org.apache.lucene.search.spell.Dictionary
dictionary
static String
LOCATION
Location of the source data - either a path to a file, or null for the current IndexReader.protected org.apache.lucene.search.suggest.Lookup
lookup
static String
LOOKUP_IMPL
Fully-qualified class of theLookup
implementation.protected String
lookupImpl
protected org.apache.lucene.index.IndexReader
reader
protected String
sourceLocation
static String
STORE_DIR
Name of the location where to persist the dictionary.protected File
storeDir
protected float
threshold
static String
THRESHOLD_TOKEN_FREQUENCY
Minimum frequency of terms to consider when building the dictionary.-
Fields inherited from class org.apache.solr.spelling.SolrSpellChecker
analyzer, DEFAULT_DICTIONARY_NAME, DICTIONARY_NAME, field, FIELD, FIELD_TYPE, fieldTypeName, name
-
-
Constructor Summary
Constructors Constructor Description Suggester()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
build(SolrCore core, SolrIndexSearcher searcher)
(re)Builds the spelling index.SpellingResult
getSuggestions(SpellingOptions options)
Get suggestions for the given query.String
init(NamedList config, SolrCore core)
void
reload(SolrCore core, SolrIndexSearcher searcher)
Reloads the index.-
Methods inherited from class org.apache.solr.spelling.SolrSpellChecker
getAccuracy, getDictionaryName, getQueryAnalyzer, getStringDistance, isSuggestionsMayOverlap, mergeSuggestions
-
-
-
-
Field Detail
-
LOCATION
public static final String LOCATION
Location of the source data - either a path to a file, or null for the current IndexReader.- See Also:
- Constant Field Values
-
LOOKUP_IMPL
public static final String LOOKUP_IMPL
Fully-qualified class of theLookup
implementation.- See Also:
- Constant Field Values
-
THRESHOLD_TOKEN_FREQUENCY
public static final String THRESHOLD_TOKEN_FREQUENCY
Minimum frequency of terms to consider when building the dictionary.- See Also:
- Constant Field Values
-
STORE_DIR
public static final String STORE_DIR
Name of the location where to persist the dictionary. If this location is relative then the data will be stored under the core's dataDir. If this is null the storing will be disabled.- See Also:
- Constant Field Values
-
sourceLocation
protected String sourceLocation
-
storeDir
protected File storeDir
-
threshold
protected float threshold
-
dictionary
protected org.apache.lucene.search.spell.Dictionary dictionary
-
reader
protected org.apache.lucene.index.IndexReader reader
-
lookup
protected org.apache.lucene.search.suggest.Lookup lookup
-
lookupImpl
protected String lookupImpl
-
core
protected SolrCore core
-
-
Method Detail
-
init
public String init(NamedList config, SolrCore core)
- Overrides:
init
in classSolrSpellChecker
-
build
public void build(SolrCore core, SolrIndexSearcher searcher) throws IOException
Description copied from class:SolrSpellChecker
(re)Builds the spelling index. May be a NOOP if the implementation doesn't require building, or can't be rebuilt.- Specified by:
build
in classSolrSpellChecker
- Throws:
IOException
-
reload
public void reload(SolrCore core, SolrIndexSearcher searcher) throws IOException
Description copied from class:SolrSpellChecker
Reloads the index. Useful if an external process is responsible for building the spell checker.- Specified by:
reload
in classSolrSpellChecker
- Throws:
IOException
- If there is a low-level I/O error.
-
getSuggestions
public SpellingResult getSuggestions(SpellingOptions options) throws IOException
Description copied from class:SolrSpellChecker
Get 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:
getSuggestions
in classSolrSpellChecker
- Parameters:
options
- TheSpellingOptions
to use- Returns:
- The
SpellingResult
suggestions - Throws:
IOException
- if there is an error producing suggestions
-
-