## org.apache.lucene.queryParser.complexPhrase
Class ComplexPhraseQueryParser

    java.lang.Object
      org.apache.lucene.queryParser.QueryParser
          org.apache.lucene.queryParser.complexPhrase.ComplexPhraseQueryParser

All Implemented Interfaces:
  org.apache.lucene.queryParser.QueryParserConstants

    public class ComplexPhraseQueryParser

extends org.apache.lucene.queryParser.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.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, BAREOPER, 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, 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, TopLevelQuery`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ComplexPhraseQueryParser

    public ComplexPhraseQueryParser(org.apache.lucene.util.Version matchVersion,
                                    String f,
                                    org.apache.lucene.analysis.Analyzer a)

Method Detail

### getFieldQuery

    protected org.apache.lucene.search.Query getFieldQuery(String field,
                                                           String queryText,
                                                           int slop)

  Overrides:
    `getFieldQuery` in class `org.apache.lucene.queryParser.QueryParser`

### parse

    public org.apache.lucene.search.Query parse(String query)
                                         throws org.apache.lucene.queryParser.ParseException

  Overrides:
    `parse` in class `org.apache.lucene.queryParser.QueryParser`
  Throws:
    `org.apache.lucene.queryParser.ParseException`

### newTermQuery

    protected org.apache.lucene.search.Query newTermQuery(org.apache.lucene.index.Term term)

  Overrides:
    `newTermQuery` in class `org.apache.lucene.queryParser.QueryParser`

### getWildcardQuery

    protected org.apache.lucene.search.Query getWildcardQuery(String field,
                                                              String termStr)
                                                       throws org.apache.lucene.queryParser.ParseException

  Overrides:
    `getWildcardQuery` in class `org.apache.lucene.queryParser.QueryParser`
  Throws:
    `org.apache.lucene.queryParser.ParseException`

### getRangeQuery

    protected org.apache.lucene.search.Query getRangeQuery(String field,
                                                           String part1,
                                                           String part2,
                                                           boolean inclusive)
                                                    throws org.apache.lucene.queryParser.ParseException

  Overrides:
    `getRangeQuery` in class `org.apache.lucene.queryParser.QueryParser`
  Throws:
    `org.apache.lucene.queryParser.ParseException`

### newRangeQuery

    protected org.apache.lucene.search.Query newRangeQuery(String field,
                                                           String part1,
                                                           String part2,
                                                           boolean inclusive)

  Overrides:
    `newRangeQuery` in class `org.apache.lucene.queryParser.QueryParser`

### getFuzzyQuery

    protected org.apache.lucene.search.Query getFuzzyQuery(String field,
                                                           String termStr,
                                                           float minSimilarity)
                                                    throws org.apache.lucene.queryParser.ParseException

  Overrides:
    `getFuzzyQuery` in class `org.apache.lucene.queryParser.QueryParser`
  Throws:
    `org.apache.lucene.queryParser.ParseException`