Package org.apache.solr.search
Class QParser
java.lang.Object
org.apache.solr.search.QParser
- Direct Known Subclasses:
AbstractVectorQParserBase,CrossCollectionJoinQParser,DisMaxQParser,ExportQParserPlugin.ExportQParser,ExtendedDismaxQParser,FiltersQParser,FunctionQParser,GraphQueryParser,HashRangeQParser,LuceneQParser,MinHashQParser,RankQParserPlugin.RankQParser,SimpleMLTQParser,SpatialFilterQParser
Note: This API is experimental and may change in non backward-compatible ways in the
future
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected intprotected org.apache.solr.common.params.SolrParamsprotected intprotected org.apache.solr.common.params.SolrParamsprotected Stringprotected org.apache.lucene.search.Queryprotected intprotected SolrQueryRequestprotected Stringprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionQParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req) Constructor for the QParser -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDebugInfo(org.apache.solr.common.util.NamedList<Object> debugInfo) String[]intgetFlags()org.apache.lucene.search.Queryorg.apache.solr.common.params.SolrParamscheck both local and global paramsorg.apache.solr.common.params.SolrParamsstatic 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.intorg.apache.lucene.search.QuerygetQuery()Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.getReq()getSortSpec(boolean useGlobalParams) booleanisFilter()abstract org.apache.lucene.search.Queryparse()Create and return theQueryobject represented byqstr.org.apache.lucene.queries.function.ValueSourceParse the string into aValueSourceinstead of aQuery.voidsetFlags(int flags) voidsetIsFilter(boolean isFilter) voidsetLocalParams(org.apache.solr.common.params.SolrParams localParams) voidsetParams(org.apache.solr.common.params.SolrParams params) voidsetReq(SolrQueryRequest req) voidCreate a new QParser for parsing an embedded sub-query
-
Field Details
-
FLAG_FILTER
public static final int FLAG_FILTER- See Also:
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
qstr
-
params
protected org.apache.solr.common.params.SolrParams params -
localParams
protected org.apache.solr.common.params.SolrParams localParams -
req
-
recurseCount
protected int recurseCount -
flags
protected int flags- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
query
protected org.apache.lucene.search.Query query -
stringIncludingLocalParams
-
valFollowedParams
protected boolean valFollowedParams -
localParamsEnd
protected int localParamsEnd
-
-
Constructor Details
-
QParser
public QParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req) Constructor for the QParser- Parameters:
qstr- The query string to be parsedlocalParams- Params scoped to this query, customizing the parsing. Null if none. Most params the parser needs are resolved here first, overlaying the request. See https://solr.apache.org/guide/solr/latest/query-guide/local-params.htmlparams- Params for the request, taken fromSolrQueryRequest.getParams(); not nullreq- The originalSolrQueryRequest.
-
-
Method Details
-
setFlags
public void setFlags(int flags) - WARNING: This API is experimental and might change in incompatible ways in the next release.
-
getFlags
public int getFlags()- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
isFilter
public 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
-
setIsFilter
public void setIsFilter(boolean isFilter) - WARNING: This API is experimental and might change in incompatible ways in the next release.
-
parse
Create 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:
-
getLocalParams
public org.apache.solr.common.params.SolrParams getLocalParams() -
setLocalParams
public void setLocalParams(org.apache.solr.common.params.SolrParams localParams) -
getParams
public org.apache.solr.common.params.SolrParams getParams() -
setParams
public void setParams(org.apache.solr.common.params.SolrParams params) -
getReq
-
setReq
-
getString
-
setString
-
getQuery
Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result. A null return is possible!- Throws:
SyntaxError
-
getParam
check both local and global params -
subQuery
Create a new QParser for parsing an embedded sub-query- Throws:
SyntaxError
-
getSortSpec
- Parameters:
useGlobalParams- look up sort, start, rows in global params if not in local params- Returns:
- the sort specification
- Throws:
SyntaxError
-
getDefaultHighlightFields
-
getHighlightQuery
- Throws:
SyntaxError
-
addDebugInfo
-
getPrefixQueryMinPrefixLength
public int getPrefixQueryMinPrefixLength() -
parseAsValueSource
Parse the string into aValueSourceinstead of aQuery. Solr calls this in most places that "function queries" go. Overridden byFunctionQParser.- Throws:
SyntaxError
-
getParser
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
-
getParser
public 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
-
getParser
public 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.
-