org.apache.lucene.queryParser.analyzing
Class AnalyzingQueryParser
- QueryParserConstants
public class AnalyzingQueryParser
Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys
are also passed through the given analyzer, but
?
and
*
don't get
removed from the search terms.
Warning: This class should only be used with analyzers that do not use stopwords
or that add tokens. Also, several stemming analyzers are inappropriate: for example, GermanAnalyzer
will turn
Häuser
into
hau
, but
H?user
will
become
h?user
when using this parser and thus no match would be found (i.e.
using this parser will be no improvement over QueryParser in such cases).
- Ronnie Kolehmainen (ronnie.kolehmainen at ub.uu.se)
AND , Boost , CARAT , COLON , DEFAULT , EOF , FUZZY_SLOP , LPAREN , MINUS , NOT , NUMBER , OR , PLUS , PREFIXTERM , QUOTED , RANGEEX_END , RANGEEX_GOOP , RANGEEX_QUOTED , RANGEEX_START , RANGEEX_TO , RANGEIN_END , RANGEIN_GOOP , RANGEIN_QUOTED , RANGEIN_START , RANGEIN_TO , RPAREN , RangeEx , RangeIn , TERM , WILDTERM , _ESCAPED_CHAR , _NUM_CHAR , _TERM_CHAR , _TERM_START_CHAR , _WHITESPACE , tokenImage |
protected Query | getFuzzyQuery(String field, String termStr, float minSimilarity) - Called when parser parses an input term token that has the fuzzy suffix (~) appended.
|
protected Query | getPrefixQuery(String field, String termStr) - Called when parser parses an input term
token that uses prefix notation; that is, contains a single '*' wildcard
character as its last character.
|
protected Query | getRangeQuery(String field, String part1, String part2, boolean inclusive) - Overrides super class, by passing terms through analyzer.
|
protected Query | getWildcardQuery(String field, String termStr) - Called when parser
parses an input term token that contains one or more wildcard
characters (? and *), but is not a prefix term token (one
that has just a single * character at the end)
Depending on analyzer and settings, a wildcard term may (most probably will)
be lower-cased automatically.
|
Clause , Conjunction , Modifiers , Query , ReInit , ReInit , Term , addClause , disable_tracing , enable_tracing , escape , generateParseException , getAnalyzer , getBooleanQuery , getBooleanQuery , getDefaultOperator , getField , getFieldQuery , getFieldQuery , getFieldQuery , getFieldQuery , getFuzzyMinSim , getFuzzyPrefixLength , getFuzzyQuery , getFuzzyQuery , getLocale , getLowercaseExpandedTerms , getLowercaseWildcardTerms , getNextToken , getOperator , getPhraseSlop , getPrefixQuery , getRangeQuery , getRangeQuery , getToken , getWildcardQuery , main , parse , parse , setDefaultOperator , setFuzzyMinSim , setFuzzyPrefixLength , setLocale , setLowercaseExpandedTerms , setLowercaseWildcardTerms , setOperator , setPhraseSlop |
AnalyzingQueryParser
public AnalyzingQueryParser(String field,
Analyzer analyzer)
Constructs a query parser.
field
- the default field for query terms.analyzer
- used to find terms in the query text.
getFuzzyQuery
protected Query getFuzzyQuery(String field,
String termStr,
float minSimilarity)
throws ParseException
Called when parser parses an input term token that has the fuzzy suffix (~) appended.
Depending on analyzer and settings, a fuzzy term may (most probably will)
be lower-cased automatically. It
will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
- getFuzzyQuery in interface QueryParser
field
- Name of the field query will use.termStr
- Term token to use for building term for the query
- Resulting
Query
built for the term
getPrefixQuery
protected Query getPrefixQuery(String field,
String termStr)
throws ParseException
Called when parser parses an input term
token that uses prefix notation; that is, contains a single '*' wildcard
character as its last character. Since this is a special case
of generic wildcard term, and such a query can be optimized easily,
this usually results in a different query object.
Depending on analyzer and settings, a prefix term may (most probably will)
be lower-cased automatically. It
will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
- getPrefixQuery in interface QueryParser
field
- Name of the field query will use.termStr
- Term token to use for building term for the query
(without trailing '*' character!)
- Resulting
Query
built for the term
getRangeQuery
protected Query getRangeQuery(String field,
String part1,
String part2,
boolean inclusive)
throws ParseException
Overrides super class, by passing terms through analyzer.
- getRangeQuery in interface QueryParser
getWildcardQuery
protected Query getWildcardQuery(String field,
String termStr)
throws ParseException
Called when parser
parses an input term token that contains one or more wildcard
characters (? and *), but is not a prefix term token (one
that has just a single * character at the end)
Depending on analyzer and settings, a wildcard term may (most probably will)
be lower-cased automatically. It
will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
- getWildcardQuery in interface QueryParser
field
- Name of the field query will use.termStr
- Term token that contains one or more wild card
characters (? or *), but is not simple prefix term
- Resulting
Query
built for the term
Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.