org.apache.solr.handler
Class SpellCheckerRequestHandler

java.lang.Object
  extended by org.apache.solr.handler.RequestHandlerBase
      extended by org.apache.solr.handler.SpellCheckerRequestHandler
All Implemented Interfaces:
SolrInfoMBean, SolrRequestHandler, SolrCoreAware

Deprecated. Use SpellCheckComponent instead. See also https://issues.apache.org/jira/browse/SOLR-474 and https://issues.apache.org/jira/browse/SOLR-485

@Deprecated
public class SpellCheckerRequestHandler
extends RequestHandlerBase
implements SolrCoreAware

Takes a string (e.g. a query string) as the value of the "q" parameter and looks up alternative spelling suggestions in the spellchecker. The spellchecker used by this handler is the Lucene contrib SpellChecker.

The results identifies the original words echoing it as an entry with the name of "words" and original word value. It also identifies if the requested "words" is contained in the index through the use of the exist true/false name value. Examples of these output parameters in the standard output format is as follows:

<str name="words">facial</str>
<str name="exist">true</str> 

If a query string parameter of "extendedResults" is used, then each word within the "q" parameter (seperated by a space or +) will be iterated through the spell checker and will be wrapped in an NamedList. Each word will then get its own set of results: words, exists, and suggestions.

NOTE: Query terms are simply split on whitespace when using extendedResults mode. This is may not be adequate. See the SpellCheckComponent for alternatives.

Also note that multiword queries will be treated as a single term if extendedResults is false. This may or may not make sense depending on how the spelling field was indexed.

Examples of the use of the standard ouput (XML) without and with the use of the "extendedResults" parameter are as follows.

The following URL examples were configured with the solr.SpellCheckerRequestHandler named as "/spellchecker".

Without the use of "extendedResults" and one word spelled correctly: facial

http://.../spellchecker?indent=on&onlyMorePopular=true&accuracy=.6&suggestionCount=20&q=facial
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
   <int name="status">0</int>
   <int name="QTime">6</int>
</lst>
<str name="words">facial</str>
<str name="exist">true</str>
<arr name="suggestions">
   <str>faciale</str>
   <str>faucial</str>
   <str>fascial</str>
   <str>facing</str>
   <str>faciei</str>
   <str>facialis</str>
   <str>social</str>
   <str>facile</str>
   <str>spacial</str>
   <str>glacial</str>
   <str>marcial</str>
   <str>facies</str>
   <str>facio</str>
</arr>
</response>   

Without the use of "extendedResults" and two words, one spelled correctly and one misspelled: facial salophosphoprotein

http://.../spellchecker?indent=on&onlyMorePopular=true&accuracy=.6&suggestionCount=20&q=facial+salophosphoprotein
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
   <int name="status">0</int>
   <int name="QTime">18</int>
</lst>
<str name="words">facial salophosphoprotein</str>
<str name="exist">false</str>
<arr name="suggestions">
   <str>sialophosphoprotein</str>
</arr>
</response>  

With the use of "extendedResults" and two words, one spelled correctly and one misspelled: facial salophosphoprotein

http://.../spellchecker?indent=on&onlyMorePopular=true&accuracy=.6&suggestionCount=20&extendedResults=true&q=facial+salophosphoprotein
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
   <int name="status">0</int>
   <int name="QTime">23</int>
</lst>
<lst name="result">
  <lst name="facial">
    <int name="frequency">1</int>
    <lst name="suggestions">
      <lst name="faciale"><int name="frequency">1</int></lst>
      <lst name="faucial"><int name="frequency">1</int></lst>
      <lst name="fascial"><int name="frequency">1</int></lst>
      <lst name="facing"><int name="frequency">1</int></lst>
      <lst name="faciei"><int name="frequency">1</int></lst>
      <lst name="facialis"><int name="frequency">1</int></lst>
      <lst name="social"><int name="frequency">1</int></lst>
      <lst name="facile"><int name="frequency">1</int></lst>
      <lst name="spacial"><int name="frequency">1</int></lst>
      <lst name="glacial"><int name="frequency">1</int></lst>
      <lst name="marcial"><int name="frequency">1</int></lst>
      <lst name="facies"><int name="frequency">1</int></lst>
      <lst name="facio"><int name="frequency">1</int></lst>
    </lst>
  </lst>
  <lst name="salophosphoprotein">
    <int name="frequency">0</int>
    <lst name="suggestions"> 
      <lst name="sialophosphoprotein"><int name="frequency">1</int></lst>
      <lst name="phosphoprotein"><int name="frequency">1</int></lst>
      <lst name="phosphoproteins"><int name="frequency">1</int></lst>
      <lst name="alphalipoprotein"><int name="frequency">1</int></lst>
    </lst>
  </lst>
</lst>
</response>  

See Also:
The Lucene Spellchecker documentation

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean
SolrInfoMBean.Category
 
Field Summary
protected static String ACCURACY
          Deprecated.  
protected  org.apache.solr.common.params.SolrParams args
          Deprecated.  
protected static float DEFAULT_ACCURACY
          Deprecated.  
protected static float DEFAULT_DICTIONARY_THRESHOLD
          Deprecated.  
protected static boolean DEFAULT_EXTENDED_RESULTS
          Deprecated.  
protected static boolean DEFAULT_MORE_POPULAR
          Deprecated.  
protected static int DEFAULT_SUGGESTION_COUNT
          Deprecated.  
protected static String DICTIONARY_PREFIX
          Deprecated.  
protected  String dirDescription
          Deprecated.  
protected static String EXTENDED
          Deprecated.  
protected static String INDEX_DIR
          Deprecated.  
protected static String POPULAR
          Deprecated.  
protected static String PREFIX
          Deprecated.  
protected static String QUERY_PREFIX
          Deprecated.  
protected static String SOURCE_FIELD
          Deprecated.  
protected  Directory spellcheckerIndexDir
          Deprecated.  
protected static String SUGGESTIONS
          Deprecated.  
protected  String termSourceField
          Deprecated.  
protected static String THRESHOLD
          Deprecated.  
 
Fields inherited from class org.apache.solr.handler.RequestHandlerBase
appends, defaults, httpCaching, initArgs, invariants
 
Constructor Summary
SpellCheckerRequestHandler()
          Deprecated.  
 
Method Summary
 String getDescription()
          Deprecated. Simple one or two line description
protected  Dictionary getDictionary(SolrQueryRequest req)
          Deprecated. Returns a dictionary to be used when building the spell-checker index.
 URL[] getDocs()
          Deprecated. Documentation URL list.
 String getSource()
          Deprecated. CVS Source, SVN Source, etc
 String getSourceId()
          Deprecated. CVS Id, SVN Id, etc
 String getVersion()
          Deprecated. Simple common usage version, e.g.
 void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
          Deprecated. Processes the following query string parameters: q, extendedResults, cmd rebuild, cmd reopen, accuracy, suggestionCount, restrictToField, and onlyMorePopular.
 void inform(SolrCore core)
          Deprecated.  
 void init(org.apache.solr.common.util.NamedList args)
          Deprecated. Initializes the SolrRequestHandler by creating three SolrParams named.
 
Methods inherited from class org.apache.solr.handler.RequestHandlerBase
getCategory, getInitArgs, getName, getStatistics, handleRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spellcheckerIndexDir

protected Directory spellcheckerIndexDir
Deprecated. 

dirDescription

protected String dirDescription
Deprecated. 

termSourceField

protected String termSourceField
Deprecated. 

PREFIX

protected static final String PREFIX
Deprecated. 
See Also:
Constant Field Values

QUERY_PREFIX

protected static final String QUERY_PREFIX
Deprecated. 
See Also:
Constant Field Values

DICTIONARY_PREFIX

protected static final String DICTIONARY_PREFIX
Deprecated. 
See Also:
Constant Field Values

SOURCE_FIELD

protected static final String SOURCE_FIELD
Deprecated. 
See Also:
Constant Field Values

INDEX_DIR

protected static final String INDEX_DIR
Deprecated. 
See Also:
Constant Field Values

THRESHOLD

protected static final String THRESHOLD
Deprecated. 
See Also:
Constant Field Values

ACCURACY

protected static final String ACCURACY
Deprecated. 
See Also:
Constant Field Values

SUGGESTIONS

protected static final String SUGGESTIONS
Deprecated. 
See Also:
Constant Field Values

POPULAR

protected static final String POPULAR
Deprecated. 
See Also:
Constant Field Values

EXTENDED

protected static final String EXTENDED
Deprecated. 
See Also:
Constant Field Values

DEFAULT_ACCURACY

protected static final float DEFAULT_ACCURACY
Deprecated. 
See Also:
Constant Field Values

DEFAULT_SUGGESTION_COUNT

protected static final int DEFAULT_SUGGESTION_COUNT
Deprecated. 
See Also:
Constant Field Values

DEFAULT_MORE_POPULAR

protected static final boolean DEFAULT_MORE_POPULAR
Deprecated. 
See Also:
Constant Field Values

DEFAULT_EXTENDED_RESULTS

protected static final boolean DEFAULT_EXTENDED_RESULTS
Deprecated. 
See Also:
Constant Field Values

DEFAULT_DICTIONARY_THRESHOLD

protected static final float DEFAULT_DICTIONARY_THRESHOLD
Deprecated. 
See Also:
Constant Field Values

args

protected org.apache.solr.common.params.SolrParams args
Deprecated. 
Constructor Detail

SpellCheckerRequestHandler

public SpellCheckerRequestHandler()
Deprecated. 
Method Detail

init

public void init(org.apache.solr.common.util.NamedList args)
Deprecated. 
Description copied from class: RequestHandlerBase
Initializes the SolrRequestHandler by creating three SolrParams named.
NameDescription
defaultsContains all of the named arguments contained within the list element named "defaults".
appendsContains all of the named arguments contained within the list element named "appends".
invariantsContains all of the named arguments contained within the list element named "invariants".
Example:
 <lst name="defaults">
 <str name="echoParams">explicit</str>
 <str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0</str>
 <str name="mm">2<-1 5<-2 6<90%</str>
 <str name="bq">incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2</str>
 </lst>
 <lst name="appends">
 <str name="fq">inStock:true</str>
 </lst>

 <lst name="invariants">
 <str name="facet.field">cat</str>
 <str name="facet.field">manu_exact</str>
 <str name="facet.query">price:[* TO 500]</str>
 <str name="facet.query">price:[500 TO *]</str>
 </lst>
 

Specified by:
init in interface SolrRequestHandler
Overrides:
init in class RequestHandlerBase
Parameters:
args - The NamedList to initialize from
See Also:
RequestHandlerBase.handleRequest(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse), RequestHandlerBase.handleRequestBody(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse), SolrPluginUtils.setDefaults(org.apache.solr.request.SolrQueryRequest, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams), See also the example solrconfig.xml located in the Solr codebase (example/solr/conf).

inform

public void inform(SolrCore core)
Deprecated. 
Specified by:
inform in interface SolrCoreAware

handleRequestBody

public void handleRequestBody(SolrQueryRequest req,
                              SolrQueryResponse rsp)
                       throws Exception
Deprecated. 
Processes the following query string parameters: q, extendedResults, cmd rebuild, cmd reopen, accuracy, suggestionCount, restrictToField, and onlyMorePopular.

Specified by:
handleRequestBody in class RequestHandlerBase
Throws:
Exception

getDictionary

protected Dictionary getDictionary(SolrQueryRequest req)
Deprecated. 
Returns a dictionary to be used when building the spell-checker index. Override the method for custom dictionary


getVersion

public String getVersion()
Deprecated. 
Description copied from interface: SolrInfoMBean
Simple common usage version, e.g. 2.0

Specified by:
getVersion in interface SolrInfoMBean
Specified by:
getVersion in class RequestHandlerBase

getDescription

public String getDescription()
Deprecated. 
Description copied from interface: SolrInfoMBean
Simple one or two line description

Specified by:
getDescription in interface SolrInfoMBean
Specified by:
getDescription in class RequestHandlerBase

getSourceId

public String getSourceId()
Deprecated. 
Description copied from interface: SolrInfoMBean
CVS Id, SVN Id, etc

Specified by:
getSourceId in interface SolrInfoMBean
Specified by:
getSourceId in class RequestHandlerBase

getSource

public String getSource()
Deprecated. 
Description copied from interface: SolrInfoMBean
CVS Source, SVN Source, etc

Specified by:
getSource in interface SolrInfoMBean
Specified by:
getSource in class RequestHandlerBase

getDocs

public URL[] getDocs()
Deprecated. 
Description copied from interface: SolrInfoMBean
Documentation URL list.

Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...

Specified by:
getDocs in interface SolrInfoMBean
Overrides:
getDocs in class RequestHandlerBase