org.apache.solr.spelling
Class SolrSpellChecker

java.lang.Object
  extended by org.apache.solr.spelling.SolrSpellChecker
Direct Known Subclasses:
AbstractLuceneSpellChecker, Suggester

public abstract class SolrSpellChecker
extends Object

Refer to SpellCheckComponent for more details.

Since:
solr 1.3

Field Summary
protected  Analyzer analyzer
           
static String DEFAULT_DICTIONARY_NAME
           
static String DICTIONARY_NAME
           
protected  String field
           
static String FIELD
           
static String FIELD_TYPE
           
protected  String fieldTypeName
           
protected  String name
          Dictionary name
 
Constructor Summary
SolrSpellChecker()
           
 
Method Summary
abstract  void build(SolrCore core, SolrIndexSearcher searcher)
          (re)Builds the spelling index.
 String getDictionaryName()
           
 Analyzer getQueryAnalyzer()
           
 SpellingResult getSuggestions(Collection<Token> tokens, IndexReader reader)
          Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)
 SpellingResult getSuggestions(Collection<Token> tokens, IndexReader reader, boolean onlyMorePopular, boolean extendedResults)
          Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)
 SpellingResult getSuggestions(Collection<Token> tokens, IndexReader reader, int count)
          Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)
abstract  SpellingResult getSuggestions(Collection<Token> tokens, IndexReader reader, int count, boolean onlyMorePopular, boolean extendedResults)
          Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)
 SpellingResult getSuggestions(SpellingOptions options)
          Get suggestions for the given query.
 String init(NamedList config, SolrCore core)
           
abstract  void reload(SolrCore core, SolrIndexSearcher searcher)
          Reloads the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DICTIONARY_NAME

public static final String DICTIONARY_NAME
See Also:
Constant Field Values

DEFAULT_DICTIONARY_NAME

public static final String DEFAULT_DICTIONARY_NAME
See Also:
Constant Field Values

FIELD

public static final String FIELD
See Also:
Constant Field Values

FIELD_TYPE

public static final String FIELD_TYPE
See Also:
Constant Field Values

name

protected String name
Dictionary name


analyzer

protected Analyzer analyzer

field

protected String field

fieldTypeName

protected String fieldTypeName
Constructor Detail

SolrSpellChecker

public SolrSpellChecker()
Method Detail

init

public String init(NamedList config,
                   SolrCore core)

getQueryAnalyzer

public Analyzer getQueryAnalyzer()

getDictionaryName

public String getDictionaryName()

reload

public abstract void reload(SolrCore core,
                            SolrIndexSearcher searcher)
                     throws IOException
Reloads the index. Useful if an external process is responsible for building the spell checker.

Throws:
IOException

build

public abstract void build(SolrCore core,
                           SolrIndexSearcher searcher)
(re)Builds the spelling index. May be a NOOP if the implementation doesn't require building, or can't be rebuilt.


getSuggestions

@Deprecated
public SpellingResult getSuggestions(Collection<Token> tokens,
                                                IndexReader reader)
                              throws IOException
Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)

Assumes count = 1, onlyMorePopular = false, extendedResults = false

Throws:
IOException
See Also:
getSuggestions(Collection, org.apache.lucene.index.IndexReader, int, boolean, boolean)

getSuggestions

@Deprecated
public SpellingResult getSuggestions(Collection<Token> tokens,
                                                IndexReader reader,
                                                int count)
                              throws IOException
Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)

Assumes onlyMorePopular = false, extendedResults = false

Throws:
IOException
See Also:
getSuggestions(Collection, org.apache.lucene.index.IndexReader, int, boolean, boolean)

getSuggestions

@Deprecated
public SpellingResult getSuggestions(Collection<Token> tokens,
                                                IndexReader reader,
                                                boolean onlyMorePopular,
                                                boolean extendedResults)
                              throws IOException
Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)

Assumes count = 1.

Throws:
IOException
See Also:
getSuggestions(Collection, org.apache.lucene.index.IndexReader, int, boolean, boolean)

getSuggestions

@Deprecated
public abstract SpellingResult getSuggestions(Collection<Token> tokens,
                                                         IndexReader reader,
                                                         int count,
                                                         boolean onlyMorePopular,
                                                         boolean extendedResults)
                                       throws IOException
Deprecated. This method will be removed in 4.x in favor of getSuggestions(org.apache.solr.spelling.SpellingOptions)

Get suggestions for the given query. Tokenizes the query using a field appropriate Analyzer. The SpellingResult.getSuggestions() suggestions must be ordered by best suggestion first.

Parameters:
tokens - The Tokens to be spell checked.
reader - The (optional) IndexReader. If there is not IndexReader, than extendedResults are not possible
count - The maximum number of suggestions to return
onlyMorePopular - TODO
extendedResults - TODO
Throws:
IOException

getSuggestions

public SpellingResult getSuggestions(SpellingOptions options)
                              throws IOException
Get suggestions for the given query. Tokenizes the query using a field appropriate Analyzer. The SpellingResult.getSuggestions() suggestions must be ordered by best suggestion first.

Note: This method is abstract in Solr 4.0 and beyond and is the recommended way of implementing the spell checker. For now, it calls getSuggestions(java.util.Collection, org.apache.lucene.index.IndexReader, boolean, boolean).

Parameters:
options - The SpellingOptions to use
Returns:
The SpellingResult suggestions
Throws:
IOException - if there is an error producing suggestions