org.apache.solr.search

## Class QParser

- java.lang.Object
- - org.apache.solr.search.QParser

- Direct Known Subclasses:
    BlockJoinParentQParser, CloudMLTQParser, DisMaxQParser, ExportQParserPlugin.ExportQParser, ExtendedDismaxQParser, FunctionQParser, GraphQueryParser, LuceneQParser, SimpleMLTQParser, SpatialFilterQParser

      public abstract class QParser
      extends Object

  Note: This API is experimental and may change in non backward-compatible ways in the future

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SolrParams` | `localParams`
    `protected int` | `localParamsEnd`
    `protected SolrParams` | `params`
    `protected String` | `qstr`
    `protected Query` | `query`
    `protected int` | `recurseCount`
    `protected SolrQueryRequest` | `req`
    `protected String` | `stringIncludingLocalParams`
    `protected boolean` | `valFollowedParams`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req)` Constructor for the QParser

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDebugInfo(NamedList<Object> debugInfo)`
    `String[]` | `getDefaultHighlightFields()`
    `Query` | `getHighlightQuery()`
    `SolrParams` | `getLocalParams()`
    `String` | `getParam(String name)` check both local and global params
    `SolrParams` | `getParams()`
    `static QParser` | `getParser(String qstr, SolrQueryRequest req)` Create a `QParser` to parse `qstr`, using the "lucene" (QParserPlugin.DEFAULT_QTYPE) query parser.
    `static QParser` | `getParser(String qstr, String defaultParser, SolrQueryRequest req)` Create a `QParser` to parse `qstr`, assuming that the default query parser is `defaultParser`.
    `Query` | `getQuery()` Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.
    `SolrQueryRequest` | `getReq()`
    `SortSpec` | `getSort(boolean useGlobalParams)` Deprecated. Use the not misleadingly named getSortSpec() function instead.
    `SortSpec` | `getSortSpec(boolean useGlobalParams)`
    `String` | `getString()`
    `abstract Query` | `parse()` Create and return the `Query` object represented by `qstr`.
    `void` | `setLocalParams(SolrParams localParams)`
    `void` | `setParams(SolrParams params)`
    `void` | `setReq(SolrQueryRequest req)`
    `void` | `setString(String s)`
    `QParser` | `subQuery(String q, String defaultType)` Create a new QParser for parsing an embedded sub-query

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

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

- - ### Field Detail

    - #### qstr

          protected String qstr

    - #### params

          protected SolrParams params

    - #### localParams

          protected SolrParams localParams

    - #### req

          protected SolrQueryRequest req

    - #### recurseCount

          protected int recurseCount

    - #### query

          protected Query query

    - #### stringIncludingLocalParams

          protected String stringIncludingLocalParams

    - #### valFollowedParams

          protected boolean valFollowedParams

    - #### localParamsEnd

          protected int localParamsEnd

  - ### Constructor Detail

    - #### QParser

          public QParser(String qstr,
                         SolrParams localParams,
                         SolrParams params,
                         SolrQueryRequest req)

      Constructor for the QParser
      Parameters:
        `qstr` - The part of the query string specific to this parser
        `localParams` - The set of parameters that are specific to this QParser. See http://wiki.apache.org/solr/LocalParams
        `params` - The rest of the `SolrParams`
        `req` - The original `SolrQueryRequest`.

  - ### Method Detail

    - #### parse

          public abstract Query parse()
                               throws SyntaxError

      Create and return the `Query` object represented by `qstr`. Null MAY be returned to signify there was no input (e.g. no query string) to parse.
      Throws:
        `SyntaxError`
      See Also:
        `getQuery()`

    - #### getLocalParams

          public SolrParams getLocalParams()

    - #### setLocalParams

          public void setLocalParams(SolrParams localParams)

    - #### getParams

          public SolrParams getParams()

    - #### setParams

          public void setParams(SolrParams params)

    - #### getReq

          public SolrQueryRequest getReq()

    - #### setReq

          public void setReq(SolrQueryRequest req)

    - #### getString

          public String getString()

    - #### setString

          public void setString(String s)

    - #### getQuery

          public Query getQuery()
                         throws SyntaxError

      Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.
      Throws:
        `SyntaxError`

    - #### getParam

          public String getParam(String name)

      check both local and global params

    - #### subQuery

          public QParser subQuery(String q,
                                  String defaultType)
                           throws SyntaxError

      Create a new QParser for parsing an embedded sub-query
      Throws:
        `SyntaxError`

    - #### getSort

          @Deprecated
          public SortSpec getSort(boolean useGlobalParams)
                                       throws SyntaxError

      Deprecated. Use the not misleadingly named getSortSpec() function instead.
      Parameters:
        `useGlobalParams` - look up sort, start, rows in global params if not in local params
      Returns:
        the sort specification
      Throws:
        `SyntaxError`

    - #### getSortSpec

          public SortSpec getSortSpec(boolean useGlobalParams)
                               throws SyntaxError

      Parameters:
        `useGlobalParams` - look up sort, start, rows in global params if not in local params
      Returns:
        the sort specification
      Throws:
        `SyntaxError`

    - #### getDefaultHighlightFields

          public String[] getDefaultHighlightFields()

    - #### getHighlightQuery

          public Query getHighlightQuery()
                                  throws SyntaxError

      Throws:
        `SyntaxError`

    - #### addDebugInfo

          public void addDebugInfo(NamedList<Object> debugInfo)

    - #### getParser

          public static QParser getParser(String qstr,
                                          SolrQueryRequest req)
                                   throws SyntaxError

      Create a `QParser` to parse `qstr`, using the "lucene" (QParserPlugin.DEFAULT_QTYPE) query parser. The query parser may be overridden by local parameters in the query string itself. For example if qstr=`{!prefix f=myfield}foo` then the prefix query parser will be used.
      Throws:
        `SyntaxError`

    - #### getParser

          public static QParser getParser(String qstr,
                                          String defaultParser,
                                          SolrQueryRequest req)
                                   throws SyntaxError

      Create a `QParser` to parse `qstr`, assuming that the default query parser is `defaultParser`. The query parser may be overridden by local parameters in the query string itself. For example if defaultParser=`"dismax"` and qstr=`foo`, then the dismax query parser will be used to parse and construct the query object. However if qstr=`{!prefix f=myfield}foo` then the prefix query parser will be used.
      Throws:
        `SyntaxError`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.