public class ComplexPhraseQueryParser
extends org.apache.lucene.queryParser.QueryParser
Performs potentially multiple passes over Query text to parse any nested logic in PhraseQueries. - First pass takes any PhraseQuery content between quotes and stores for subsequent pass. All other query content is parsed as normal - Second pass parses any stored PhraseQuery content, checking all embedded clauses are referring to the same field and therefore can be rewritten as Span queries. All PhraseQuery clauses are expressed as ComplexPhraseQuery objects
This could arguably be done in one pass using a new QueryParser but here I am working within the constraints of the existing parser as a base class. This currently simply feeds all phrase content through an analyzer to select phrase terms - any "special" syntax such as * ~ * etc are not given special status
AND_OPERATOR, jj_nt, OR_OPERATOR, token, token_source_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, 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, STAR, TERM, tokenImage, WILDTERM| Constructor and Description |
|---|
ComplexPhraseQueryParser(org.apache.lucene.util.Version matchVersion,
String f,
org.apache.lucene.analysis.Analyzer a) |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.lucene.search.Query |
getFieldQuery(String field,
String queryText,
int slop) |
protected org.apache.lucene.search.Query |
getFuzzyQuery(String field,
String termStr,
float minSimilarity) |
protected org.apache.lucene.search.Query |
getRangeQuery(String field,
String part1,
String part2,
boolean inclusive) |
protected org.apache.lucene.search.Query |
getWildcardQuery(String field,
String termStr) |
protected org.apache.lucene.search.Query |
newRangeQuery(String field,
String part1,
String part2,
boolean inclusive) |
protected org.apache.lucene.search.Query |
newTermQuery(org.apache.lucene.index.Term term) |
org.apache.lucene.search.Query |
parse(String query) |
addClause, Clause, Conjunction, disable_tracing, enable_tracing, escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getAutoGeneratePhraseQueries, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getNextToken, getPhraseSlop, getPrefixQuery, getRangeCollator, getToken, main, Modifiers, newBooleanClause, newBooleanQuery, newFuzzyQuery, newMatchAllDocsQuery, newMultiPhraseQuery, newPhraseQuery, newPrefixQuery, newWildcardQuery, Query, ReInit, ReInit, setAllowLeadingWildcard, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setRangeCollator, Term, TopLevelQuerypublic ComplexPhraseQueryParser(org.apache.lucene.util.Version matchVersion,
String f,
org.apache.lucene.analysis.Analyzer a)
protected org.apache.lucene.search.Query getFieldQuery(String field, String queryText, int slop)
getFieldQuery in class org.apache.lucene.queryParser.QueryParserpublic org.apache.lucene.search.Query parse(String query) throws org.apache.lucene.queryParser.ParseException
parse in class org.apache.lucene.queryParser.QueryParserorg.apache.lucene.queryParser.ParseExceptionprotected org.apache.lucene.search.Query newTermQuery(org.apache.lucene.index.Term term)
newTermQuery in class org.apache.lucene.queryParser.QueryParserprotected org.apache.lucene.search.Query getWildcardQuery(String field, String termStr) throws org.apache.lucene.queryParser.ParseException
getWildcardQuery in class org.apache.lucene.queryParser.QueryParserorg.apache.lucene.queryParser.ParseExceptionprotected org.apache.lucene.search.Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws org.apache.lucene.queryParser.ParseException
getRangeQuery in class org.apache.lucene.queryParser.QueryParserorg.apache.lucene.queryParser.ParseExceptionprotected org.apache.lucene.search.Query newRangeQuery(String field, String part1, String part2, boolean inclusive)
newRangeQuery in class org.apache.lucene.queryParser.QueryParserprotected org.apache.lucene.search.Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws org.apache.lucene.queryParser.ParseException
getFuzzyQuery in class org.apache.lucene.queryParser.QueryParserorg.apache.lucene.queryParser.ParseExceptionCopyright © 2000-2012 Apache Software Foundation. All Rights Reserved.