org.apache.solr.spelling
Class SpellingQueryConverter

java.lang.Object
  extended by org.apache.solr.spelling.QueryConverter
      extended by org.apache.solr.spelling.SpellingQueryConverter
All Implemented Interfaces:
NamedListInitializedPlugin
Direct Known Subclasses:
SuggestQueryConverter

public class SpellingQueryConverter
extends QueryConverter

Converts the query string to a Collection of Lucene tokens using a regular expression. Boolean operators AND, OR, NOT are skipped. Each term is checked to determine if it is optional, required or prohibited. Required terms output a Token with the QueryConverter.REQUIRED_TERM_FLAG set. Prohibited terms output a Token with the QueryConverter.PROHIBITED_TERM_FLAG set. If the query uses the plus (+) and minus (-) to denote required and prohibited, this determination will be accurate. In the case boolean AND/OR/NOTs are used, this converter makes an uninformed guess as to whether the term would likely behave as if it is Required or Prohibited and sets the flags accordingly. These flags are used downstream to generate collations for WordBreakSolrSpellChecker, in cases where an original term is split up into multiple Tokens.

Since:
solr 1.3

Field Summary
protected  Pattern QUERY_REGEX
           
 
Fields inherited from class org.apache.solr.spelling.QueryConverter
analyzer, PROHIBITED_TERM_FLAG, REQUIRED_TERM_FLAG, TERM_IN_BOOLEAN_QUERY_FLAG, TERM_PRECEDES_NEW_BOOLEAN_OPERATOR_FLAG
 
Constructor Summary
SpellingQueryConverter()
           
 
Method Summary
protected  void analyze(Collection<Token> result, String text, int offset, int flagsAttValue)
           
 Collection<Token> convert(String original)
          Converts the original query string to a collection of Lucene Tokens.
 
Methods inherited from class org.apache.solr.spelling.QueryConverter
getAnalyzer, init, setAnalyzer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_REGEX

protected Pattern QUERY_REGEX
Constructor Detail

SpellingQueryConverter

public SpellingQueryConverter()
Method Detail

convert

public Collection<Token> convert(String original)
Converts the original query string to a collection of Lucene Tokens.

Specified by:
convert in class QueryConverter
Parameters:
original - the original query string
Returns:
a Collection of Lucene Tokens

analyze

protected void analyze(Collection<Token> result,
                       String text,
                       int offset,
                       int flagsAttValue)
                throws IOException
Throws:
IOException


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.