org.apache.lucene.queryParser
Class ThezaurusQueryParser

java.lang.Object
  extended byorg.apache.lucene.queryParser.QueryParser
      extended byorg.apache.lucene.queryParser.ThezaurusQueryParser
All Implemented Interfaces:
org.apache.lucene.queryParser.QueryParserConstants

public class ThezaurusQueryParser
extends org.apache.lucene.queryParser.QueryParser
implements org.apache.lucene.queryParser.QueryParserConstants

A QueryParser, which supports searching using synonyms.

It defines the #getFieldQuery(String, Analyzer, String) (method called when single Term is encountered in query) in manner similar to QueryParser. If a Term is encountered, it is replaced with synonyms separated with OR.

Author:
Robert Novotny

Field Summary
 
Fields inherited from class org.apache.lucene.queryParser.QueryParser
DEFAULT_OPERATOR_AND, DEFAULT_OPERATOR_OR, jj_nt, lookingAhead, token, token_source
 
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, RangeEx, RANGEEX_END, RANGEEX_GOOP, RANGEEX_QUOTED, RANGEEX_START, RANGEEX_TO, RangeIn, RANGEIN_END, RANGEIN_GOOP, RANGEIN_QUOTED, RANGEIN_START, RANGEIN_TO, RPAREN, SLOP, TERM, tokenImage, WILDTERM
 
Constructor Summary
ThezaurusQueryParser(org.apache.lucene.queryParser.CharStream stream)
          Constructor delegating the the QueryParser class.
ThezaurusQueryParser(org.apache.lucene.queryParser.QueryParserTokenManager tm)
          Constructor delegating the the QueryParser class.
ThezaurusQueryParser(java.lang.String f, org.apache.lucene.analysis.Analyzer a)
          Constructor delegating the the QueryParser class.
 
Method Summary
 ThezaurusEngine getThezaurusEngine()
          Returns associated ThezaurusEngine.
 boolean isUsingSynonyms()
          Detects, whether this QueryParser is using thezaurus engine.
 void setThezaurusEngine(ThezaurusEngine thezaurusEngine)
          Associated given ThezaurusEngine with this ThezaurusQueryParser.
 void setUsingSynonyms(boolean isUsingSynonyms)
          Toggles thezaurus engine on or off while parsing terms.
 
Methods inherited from class org.apache.lucene.queryParser.QueryParser
Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getLocale, getLowercaseWildcardTerms, getNextToken, getOperator, getPhraseSlop, getToken, main, Modifiers, parse, parse, Query, ReInit, ReInit, setLocale, setLowercaseWildcardTerms, setOperator, setPhraseSlop, Term
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThezaurusQueryParser

public ThezaurusQueryParser(java.lang.String f,
                            org.apache.lucene.analysis.Analyzer a)
Constructor delegating the the QueryParser class.

Parameters:
f - the default field for query terms.
a - used to find terms in the query text.

ThezaurusQueryParser

public ThezaurusQueryParser(org.apache.lucene.queryParser.CharStream stream)
Constructor delegating the the QueryParser class.


ThezaurusQueryParser

public ThezaurusQueryParser(org.apache.lucene.queryParser.QueryParserTokenManager tm)
Constructor delegating the the QueryParser class.

Method Detail

isUsingSynonyms

public boolean isUsingSynonyms()
Detects, whether this QueryParser is using thezaurus engine.


setUsingSynonyms

public void setUsingSynonyms(boolean isUsingSynonyms)
Toggles thezaurus engine on or off while parsing terms.


getThezaurusEngine

public ThezaurusEngine getThezaurusEngine()
Returns associated ThezaurusEngine.


setThezaurusEngine

public void setThezaurusEngine(ThezaurusEngine thezaurusEngine)
Associated given ThezaurusEngine with this ThezaurusQueryParser.

Parameters:
thezaurusEngine -