|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.queryParser.QueryParser org.apache.lucene.queryParser.complexPhrase.ComplexPhraseQueryParser
public class ComplexPhraseQueryParser
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.QueryParser |
---|
org.apache.lucene.queryParser.QueryParser.Operator |
Field Summary |
---|
Fields inherited from class org.apache.lucene.queryParser.QueryParser |
---|
AND_OPERATOR, jj_nt, OR_OPERATOR, token, token_source |
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants |
---|
_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 Summary | |
---|---|
ComplexPhraseQueryParser(org.apache.lucene.util.Version matchVersion,
String f,
org.apache.lucene.analysis.Analyzer a)
|
Method Summary | |
---|---|
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)
|
Methods inherited from class org.apache.lucene.queryParser.QueryParser |
---|
addClause, Clause, Conjunction, disable_tracing, enable_tracing, escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, 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, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setRangeCollator, Term, TopLevelQuery |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ComplexPhraseQueryParser(org.apache.lucene.util.Version matchVersion, String f, org.apache.lucene.analysis.Analyzer a)
Method Detail |
---|
protected org.apache.lucene.search.Query getFieldQuery(String field, String queryText, int slop)
getFieldQuery
in class org.apache.lucene.queryParser.QueryParser
public org.apache.lucene.search.Query parse(String query) throws org.apache.lucene.queryParser.ParseException
parse
in class org.apache.lucene.queryParser.QueryParser
org.apache.lucene.queryParser.ParseException
protected org.apache.lucene.search.Query newTermQuery(org.apache.lucene.index.Term term)
newTermQuery
in class org.apache.lucene.queryParser.QueryParser
protected org.apache.lucene.search.Query getWildcardQuery(String field, String termStr) throws org.apache.lucene.queryParser.ParseException
getWildcardQuery
in class org.apache.lucene.queryParser.QueryParser
org.apache.lucene.queryParser.ParseException
protected 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.QueryParser
org.apache.lucene.queryParser.ParseException
protected org.apache.lucene.search.Query newRangeQuery(String field, String part1, String part2, boolean inclusive)
newRangeQuery
in class org.apache.lucene.queryParser.QueryParser
protected 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.QueryParser
org.apache.lucene.queryParser.ParseException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |