Package org.apache.solr.search
Class QParser
- java.lang.Object
- 
- org.apache.solr.search.QParser
 
- 
- Direct Known Subclasses:
- CloudMLTQParser,- CrossCollectionJoinQParser,- DisMaxQParser,- ExportQParserPlugin.ExportQParser,- ExtendedDismaxQParser,- FiltersQParser,- FunctionQParser,- GraphQueryParser,- HashRangeQParser,- KnnQParser,- LuceneQParser,- MinHashQParser,- RankQParserPlugin.RankQParser,- 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 SummaryFields Modifier and Type Field Description static intFLAG_FILTERprotected intflagsprotected SolrParamslocalParamsprotected intlocalParamsEndprotected SolrParamsparamsprotected Stringqstrprotected org.apache.lucene.search.Queryqueryprotected intrecurseCountprotected SolrQueryRequestreqprotected StringstringIncludingLocalParamsprotected booleanvalFollowedParams
 - 
Constructor SummaryConstructors Constructor Description QParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req)Constructor for the QParser
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDebugInfo(NamedList<Object> debugInfo)String[]getDefaultHighlightFields()intgetFlags()org.apache.lucene.search.QuerygetHighlightQuery()SolrParamsgetLocalParams()StringgetParam(String name)check both local and global paramsSolrParamsgetParams()static QParsergetParser(String qstr, String parserName, boolean allowLocalParams, SolrQueryRequest req)Expert: Create aQParserto parseqstrusing theparserNameparser, while allowing a toggle for whether local-params may be parsed.static QParsergetParser(String qstr, String defaultParser, SolrQueryRequest req)static QParsergetParser(String qstr, SolrQueryRequest req)Create aQParserto parseqstr, using the "lucene" (QParserPlugin.DEFAULT_QTYPE) query parser.org.apache.lucene.search.QuerygetQuery()Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.SolrQueryRequestgetReq()SortSpecgetSortSpec(boolean useGlobalParams)StringgetString()booleanisFilter()abstract org.apache.lucene.search.Queryparse()Create and return theQueryobject represented byqstr.voidsetFlags(int flags)voidsetIsFilter(boolean isFilter)voidsetLocalParams(SolrParams localParams)voidsetParams(SolrParams params)voidsetReq(SolrQueryRequest req)voidsetString(String s)QParsersubQuery(String q, String defaultType)Create a new QParser for parsing an embedded sub-query
 
- 
- 
- 
Field Detail- 
FLAG_FILTERpublic static final int FLAG_FILTER - See Also:
- Constant Field Values
- WARNING: This API is experimental and might change in incompatible ways in the next release.
 
 - 
qstrprotected String qstr 
 - 
paramsprotected SolrParams params 
 - 
localParamsprotected SolrParams localParams 
 - 
reqprotected SolrQueryRequest req 
 - 
recurseCountprotected int recurseCount 
 - 
flagsprotected int flags - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
 - 
queryprotected org.apache.lucene.search.Query query 
 - 
stringIncludingLocalParamsprotected String stringIncludingLocalParams 
 - 
valFollowedParamsprotected boolean valFollowedParams 
 - 
localParamsEndprotected int localParamsEnd 
 
- 
 - 
Constructor Detail- 
QParserpublic 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 https://solr.apache.org/guide/local-parameters-in-queries.html
- params- The rest of the- SolrParams
- req- The original- SolrQueryRequest.
 
 
- 
 - 
Method Detail- 
setFlagspublic void setFlags(int flags) - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
 - 
getFlagspublic int getFlags() - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
 - 
isFilterpublic boolean isFilter() - WARNING: This API is experimental and might change in incompatible ways in the next release.
- Query is in the context of a filter, where scores don't matter
 
 - 
setIsFilterpublic void setIsFilter(boolean isFilter) - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
 - 
parsepublic abstract org.apache.lucene.search.Query parse() throws SyntaxErrorCreate and return theQueryobject represented byqstr. Null MAY be returned to signify there was no input (e.g. no query string) to parse.- Throws:
- SyntaxError
- See Also:
- getQuery()
 
 - 
getLocalParamspublic SolrParams getLocalParams() 
 - 
setLocalParamspublic void setLocalParams(SolrParams localParams) 
 - 
getParamspublic SolrParams getParams() 
 - 
setParamspublic void setParams(SolrParams params) 
 - 
getReqpublic SolrQueryRequest getReq() 
 - 
setReqpublic void setReq(SolrQueryRequest req) 
 - 
getStringpublic String getString() 
 - 
setStringpublic void setString(String s) 
 - 
getQuerypublic org.apache.lucene.search.Query getQuery() throws SyntaxErrorReturns the resulting query from this QParser, calling parse() only the first time and caching the Query result. A null return is possible!- Throws:
- SyntaxError
 
 - 
subQuerypublic QParser subQuery(String q, String defaultType) throws SyntaxError Create a new QParser for parsing an embedded sub-query- Throws:
- SyntaxError
 
 - 
getSortSpecpublic 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
 
 - 
getDefaultHighlightFieldspublic String[] getDefaultHighlightFields() 
 - 
getHighlightQuerypublic org.apache.lucene.search.Query getHighlightQuery() throws SyntaxError- Throws:
- SyntaxError
 
 - 
getParserpublic static QParser getParser(String qstr, SolrQueryRequest req) throws SyntaxError Create aQParserto parseqstr, using the "lucene" (QParserPlugin.DEFAULT_QTYPE) query parser. The query parser may be overridden by local-params in the query string itself. For example if qstr={!prefix f=myfield}foothen the prefix query parser will be used.- Throws:
- SyntaxError
 
 - 
getParserpublic static QParser getParser(String qstr, String defaultParser, SolrQueryRequest req) throws SyntaxError Create aQParserto parseqstrusing thedefaultParser. Note that local-params is only parsed when the defaultParser is "lucene" or "func".- Throws:
- SyntaxError
 
 - 
getParserpublic static QParser getParser(String qstr, String parserName, boolean allowLocalParams, SolrQueryRequest req) throws SyntaxError Expert: Create aQParserto parseqstrusing theparserNameparser, while allowing a toggle for whether local-params may be parsed. The query parser may be overridden by local parameters in the query string itself (assumingallowLocalParams. For example if parserName=dismaxand qstr=foo, then the dismax query parser will be used to parse and construct the query object. However if qstr={!prefix f=myfield}foothen the prefix query parser will be used.- Parameters:
- allowLocalParams- Whether this query parser should parse local-params syntax. Note that the "lucene" query parser natively parses local-params regardless.
- Throws:
- SyntaxError
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 
- 
 
-