Class ComplexPhraseQueryParser
- java.lang.Object
-
- org.apache.lucene.util.QueryBuilder
-
- org.apache.lucene.queryparser.classic.QueryParserBase
-
- org.apache.lucene.queryparser.classic.QueryParser
-
- org.apache.lucene.queryparser.complexPhrase.ComplexPhraseQueryParser
-
- All Implemented Interfaces:
QueryParserConstants
,CommonQueryParserConfiguration
public class ComplexPhraseQueryParser extends QueryParser
QueryParser which permits complex phrase query syntax eg "(john jon jonathan~) peters*".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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParser
QueryParser.Operator
-
Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
QueryParserBase.MethodRemovedUseAnother
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.queryparser.classic.QueryParser
jj_nt, token, token_source
-
Fields inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
AND_OPERATOR, OR_OPERATOR
-
Fields inherited from interface org.apache.lucene.queryparser.classic.QueryParserConstants
_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 Summary
Constructors Constructor Description ComplexPhraseQueryParser(Version matchVersion, java.lang.String f, Analyzer a)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Query
parse(java.lang.String query)
Parses a query string, returning aQuery
.-
Methods inherited from class org.apache.lucene.queryparser.classic.QueryParser
Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getNextToken, getToken, Modifiers, Query, ReInit, ReInit, Term, TopLevelQuery
-
Methods inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
escape, getAllowLeadingWildcard, getAnalyzeRangeTerms, getAutoGeneratePhraseQueries, getDateResolution, getDefaultOperator, getField, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getPhraseSlop, getTimeZone, init, setAllowLeadingWildcard, setAnalyzeRangeTerms, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setTimeZone
-
Methods inherited from class org.apache.lucene.util.QueryBuilder
createBooleanQuery, createBooleanQuery, createMinShouldMatchQuery, createPhraseQuery, createPhraseQuery, getAnalyzer, getEnablePositionIncrements, setAnalyzer, setEnablePositionIncrements
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.queryparser.flexible.standard.CommonQueryParserConfiguration
getAnalyzer, getEnablePositionIncrements, setEnablePositionIncrements
-
-
-
-
Method Detail
-
parse
public Query parse(java.lang.String query) throws ParseException
Description copied from class:QueryParserBase
Parses a query string, returning aQuery
.- Overrides:
parse
in classQueryParserBase
- Parameters:
query
- the query string to be parsed.- Throws:
ParseException
- if the parsing fails
-
-