public class AnalyzingQueryParser extends QueryParser
*
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).
QueryParser.Operator
QueryParserBase.MethodRemovedUseAnother
jj_nt, token, token_source
AND_OPERATOR, field, OR_OPERATOR
_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, BAREOPER, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, Range, RANGE_GOOP, RANGE_QUOTED, RANGE_TO, RANGEEX_END, RANGEEX_START, RANGEIN_END, RANGEIN_START, REGEXPTERM, RPAREN, STAR, TERM, tokenImage, WILDTERM
Constructor and Description |
---|
AnalyzingQueryParser(String field,
Analyzer analyzer) |
Modifier and Type | Method and Description |
---|---|
protected String |
analyzeSingleChunk(String field,
String termStr,
String chunk)
Returns the analyzed form for the given chunk
If the analyzer produces more than one output token from the given chunk,
a ParseException is thrown.
|
protected Query |
getFuzzyQuery(String field,
String termStr,
float minSimilarity)
Called when parser parses an input term that has the fuzzy suffix (~) appended.
|
protected Query |
getPrefixQuery(String field,
String termStr)
Called when parser parses an input term
that uses prefix notation; that is, contains a single '*' wildcard
character as its last character.
|
protected Query |
getWildcardQuery(String field,
String termStr)
Called when parser parses an input term that contains one or more wildcard
characters (like
* ), but is not a prefix term (one that has
just a single * character at the end). |
Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getNextToken, getToken, Modifiers, Query, ReInit, ReInit, Term, TopLevelQuery
addClause, analyzeMultitermTerm, escape, getAllowLeadingWildcard, getAnalyzeRangeTerms, getAutoGeneratePhraseQueries, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getField, getFieldQuery, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getMaxDeterminizedStates, getMultiTermRewriteMethod, getPhraseSlop, getRangeQuery, getRegexpQuery, getTimeZone, init, newBooleanClause, newFieldQuery, newFuzzyQuery, newMatchAllDocsQuery, newPrefixQuery, newRangeQuery, newRegexpQuery, newWildcardQuery, parse, setAllowLeadingWildcard, setAnalyzeRangeTerms, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMaxDeterminizedStates, setMultiTermRewriteMethod, setPhraseSlop, setTimeZone
createBooleanQuery, createBooleanQuery, createFieldQuery, createMinShouldMatchQuery, createPhraseQuery, createPhraseQuery, getAnalyzer, getEnablePositionIncrements, newBooleanQuery, newMultiPhraseQuery, newTermQuery, setAnalyzer, setEnablePositionIncrements
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAnalyzer, getEnablePositionIncrements, setEnablePositionIncrements
protected Query getWildcardQuery(String field, String termStr) throws ParseException
*
), but is not a prefix term (one that has
just a single *
character at the end).
Example: will be called for H?user
or for H*user
.
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 class QueryParserBase
field
- Name of the field query will use.termStr
- Term that contains one or more wildcard
characters (? or *), but is not simple prefix termQuery
built for the termParseException
- throw in overridden method to disallowprotected Query getPrefixQuery(String field, String termStr) throws ParseException
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 class QueryParserBase
field
- Name of the field query will use.termStr
- Term to use for building term for the query
(without trailing '*' character!)Query
built for the termParseException
- throw in overridden method to disallowprotected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException
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 class QueryParserBase
field
- Name of the field query will use.termStr
- Term to use for building term for the queryQuery
built for the termParseException
- throw in overridden method to disallowprotected String analyzeSingleChunk(String field, String termStr, String chunk) throws ParseException
field
- The target fieldtermStr
- The full term from which the given chunk is excerptedchunk
- The portion of the given termStr to be analyzedParseException
- when analysis returns other than one output tokenCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.