QueryParser (Lucene 10.5.0 queryparser API)
Description: declaration: package: org.apache.lucene.queryparser.surround.parser, class: QueryParser

Package org.apache.lucene.queryparser.surround.parser

# Class QueryParser

java.lang.Object
org.apache.lucene.queryparser.surround.parser.QueryParser

All Implemented Interfaces:
  `QueryParserConstants`

public class QueryParser extends Object implements QueryParserConstants
This class is generated by JavaCC. The only method that clients should need to call is `parse()`.

This parser generates queries that make use of position information (Span queries). It provides positional operators (`w` and `n`) that accept a numeric distance, as well as boolean operators (`and`, `or`, and `not`, wildcards (`*` and `?`), quoting (with `"`), and boosting (via `^`).

The operators (W, N, AND, OR, NOT) can be expressed lower-cased or upper-cased, and the non-unary operators (everything but NOT) support both infix `(a AND b AND c)` and prefix `AND(a, b, c)` notation.

The W and N operators express a positional relationship among their operands. W is ordered, and N is unordered. The distance is 1 by default, meaning the operands are adjacent, or may be provided as a prefix from 2-99. So, for example, 3W(a, b) means that terms a and b must appear within three positions of each other, or in other words, up to two terms may appear between a and b.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `Token`
  `jj_nt`
  Next token.
  `Token`
  `token`
  Current token.
  `QueryParserTokenManager`
  `token_source`
  Generated Token Manager.

  ### Fields inherited from interface org.apache.lucene.queryparser.surround.parser.QueryParserConstants

  `_DISTOP_NUM, _NUM_CHAR, _ONE_CHAR, _STAR, _TERM_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, COMMA, DEFAULT, EOF, LPAREN, N, NOT, NUMBER, OR, QUOTED, RPAREN, SUFFIXTERM, TERM, tokenImage, TRUNCQUOTED, TRUNCTERM, W`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `QueryParser()`
  `QueryParser(CharStream stream)`
  Constructor with user supplied CharStream.
  `QueryParser(QueryParserTokenManager tm)`
  Constructor with generated Token Manager.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `allowedSuffix(String suffixed)`
  `protected boolean`
  `allowedTruncation(String truncated)`
  `final SrndQuery`
  `AndQuery()`
  `protected static void`
  `checkDistanceSubQueries(DistanceQuery distq, String opName)`
  `final void`
  `disable_tracing()`
  Disable tracing.
  `final void`
  `enable_tracing()`
  Enable tracing.
  `final SrndQuery`
  `FieldsQuery()`
  `final List<SrndQuery>`
  `FieldsQueryList()`
  `ParseException`
  `generateParseException()`
  Generate ParseException.
  `protected SrndQuery`
  `getAndQuery(List<SrndQuery> queries, boolean infix, Token andToken)`
  `protected SrndQuery`
  `getDistanceQuery(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered)`
  `protected SrndQuery`
  `getFieldsQuery(SrndQuery q, ArrayList<String> fieldNames)`
  `final Token`
  `getNextToken()`
  Get the next Token.
  `protected SrndQuery`
  `getNotQuery(List<SrndQuery> queries, Token notToken)`
  `protected static int`
  `getOpDistance(String distanceOp)`
  `protected SrndQuery`
  `getOrQuery(List<SrndQuery> queries, boolean infix, Token orToken)`
  `protected SrndQuery`
  `getPrefixQuery(String prefix, boolean quoted)`
  `protected SrndQuery`
  `getTermQuery(String term, boolean quoted)`
  `final Token`
  `getToken(int index)`
  Get the specific Token.
  `protected SrndQuery`
  `getTruncQuery(String truncated)`
  `final SrndQuery`
  `NotQuery()`
  `final SrndQuery`
  `NQuery()`
  `final ArrayList<String>`
  `OptionalFields()`
  `final void`
  `OptionalWeights(SrndQuery q)`
  `final SrndQuery`
  `OrQuery()`
  `static SrndQuery`
  `parse(String query)`
  `SrndQuery`
  `parse2(String query)`
  `final SrndQuery`
  `PrefixOperatorQuery()`
  `final SrndQuery`
  `PrimaryQuery()`
  `void`
  `ReInit(CharStream stream)`
  Reinitialise.
  `void`
  `ReInit(QueryParserTokenManager tm)`
  Reinitialise.
  `final SrndQuery`
  `SimpleTerm()`
  `final SrndQuery`
  `TopSrndQuery()`
  `final boolean`
  `trace_enabled()`
  Trace enabled.
  `final SrndQuery`
  `WQuery()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### token_source

    public QueryParserTokenManager token_source
    Generated Token Manager.

  - ### token

    public Token token
    Current token.

  - ### jj_nt

    public Token jj_nt
    Next token.

- ## Constructor Details

  - ### QueryParser

    public QueryParser()

  - ### QueryParser

    public QueryParser(CharStream stream)
    Constructor with user supplied CharStream.

  - ### QueryParser

    public QueryParser(QueryParserTokenManager tm)
    Constructor with generated Token Manager.

- ## Method Details

  - ### parse

    public static SrndQuery parse(String query) throws ParseException
    Throws:
      `ParseException`

  - ### parse2

    public SrndQuery parse2(String query) throws ParseException
    Throws:
      `ParseException`

  - ### getFieldsQuery

    protected SrndQuery getFieldsQuery(SrndQuery q, ArrayList<String> fieldNames)

  - ### getOrQuery

    protected SrndQuery getOrQuery(List<SrndQuery> queries, boolean infix, Token orToken)

  - ### getAndQuery

    protected SrndQuery getAndQuery(List<SrndQuery> queries, boolean infix, Token andToken)

  - ### getNotQuery

    protected SrndQuery getNotQuery(List<SrndQuery> queries, Token notToken)

  - ### getOpDistance

    protected static int getOpDistance(String distanceOp)

  - ### checkDistanceSubQueries

    protected static void checkDistanceSubQueries(DistanceQuery distq, String opName) throws ParseException
    Throws:
      `ParseException`

  - ### getDistanceQuery

    protected SrndQuery getDistanceQuery(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered) throws ParseException
    Throws:
      `ParseException`

  - ### getTermQuery

    protected SrndQuery getTermQuery(String term, boolean quoted)

  - ### allowedSuffix

    protected boolean allowedSuffix(String suffixed)

  - ### getPrefixQuery

    protected SrndQuery getPrefixQuery(String prefix, boolean quoted)

  - ### allowedTruncation

    protected boolean allowedTruncation(String truncated)

  - ### getTruncQuery

    protected SrndQuery getTruncQuery(String truncated)

  - ### TopSrndQuery

    public final SrndQuery TopSrndQuery() throws ParseException
    Throws:
      `ParseException`

  - ### FieldsQuery

    public final SrndQuery FieldsQuery() throws ParseException
    Throws:
      `ParseException`

  - ### OptionalFields

    public final ArrayList<String> OptionalFields() throws ParseException
    Throws:
      `ParseException`

  - ### OrQuery

    public final SrndQuery OrQuery() throws ParseException
    Throws:
      `ParseException`

  - ### AndQuery

    public final SrndQuery AndQuery() throws ParseException
    Throws:
      `ParseException`

  - ### NotQuery

    public final SrndQuery NotQuery() throws ParseException
    Throws:
      `ParseException`

  - ### NQuery

    public final SrndQuery NQuery() throws ParseException
    Throws:
      `ParseException`

  - ### WQuery

    public final SrndQuery WQuery() throws ParseException
    Throws:
      `ParseException`

  - ### PrimaryQuery

    public final SrndQuery PrimaryQuery() throws ParseException
    Throws:
      `ParseException`

  - ### PrefixOperatorQuery

    public final SrndQuery PrefixOperatorQuery() throws ParseException
    Throws:
      `ParseException`

  - ### FieldsQueryList

    public final List<SrndQuery> FieldsQueryList() throws ParseException
    Throws:
      `ParseException`

  - ### SimpleTerm

    public final SrndQuery SimpleTerm() throws ParseException
    Throws:
      `ParseException`

  - ### OptionalWeights

    public final void OptionalWeights(SrndQuery q) throws ParseException
    Throws:
      `ParseException`

  - ### ReInit

    public void ReInit(CharStream stream)
    Reinitialise.

  - ### ReInit

    public void ReInit(QueryParserTokenManager tm)
    Reinitialise.

  - ### getNextToken

    public final Token getNextToken()
    Get the next Token.

  - ### getToken

    public final Token getToken(int index)
    Get the specific Token.

  - ### generateParseException

    public ParseException generateParseException()
    Generate ParseException.

  - ### trace_enabled

    public final boolean trace_enabled()
    Trace enabled.

  - ### enable_tracing

    public final void enable_tracing()
    Enable tracing.

  - ### disable_tracing

    public final void disable_tracing()
    Disable tracing.