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 Summary
Fields Modifier and Type Field Description static int
FLAG_FILTER
protected int
flags
protected org.apache.solr.common.params.SolrParams
localParams
protected int
localParamsEnd
protected org.apache.solr.common.params.SolrParams
params
protected String
qstr
protected org.apache.lucene.search.Query
query
protected int
recurseCount
protected SolrQueryRequest
req
protected String
stringIncludingLocalParams
protected boolean
valFollowedParams
-
Constructor Summary
Constructors Constructor Description QParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)
Constructor for the QParser
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDebugInfo(org.apache.solr.common.util.NamedList<Object> debugInfo)
String[]
getDefaultHighlightFields()
int
getFlags()
org.apache.lucene.search.Query
getHighlightQuery()
org.apache.solr.common.params.SolrParams
getLocalParams()
String
getParam(String name)
check both local and global paramsorg.apache.solr.common.params.SolrParams
getParams()
static QParser
getParser(String qstr, String parserName, boolean allowLocalParams, SolrQueryRequest req)
Expert: Create aQParser
to parseqstr
using theparserName
parser, while allowing a toggle for whether local-params may be parsed.static QParser
getParser(String qstr, String defaultParser, SolrQueryRequest req)
static QParser
getParser(String qstr, SolrQueryRequest req)
Create aQParser
to parseqstr
, using the "lucene" (QParserPlugin.DEFAULT_QTYPE) query parser.org.apache.lucene.search.Query
getQuery()
Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.SolrQueryRequest
getReq()
SortSpec
getSortSpec(boolean useGlobalParams)
String
getString()
boolean
isFilter()
abstract org.apache.lucene.search.Query
parse()
Create and return theQuery
object represented byqstr
.void
setFlags(int flags)
void
setIsFilter(boolean isFilter)
void
setLocalParams(org.apache.solr.common.params.SolrParams localParams)
void
setParams(org.apache.solr.common.params.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
-
-
-
Field Detail
-
FLAG_FILTER
public 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.
-
qstr
protected String qstr
-
params
protected org.apache.solr.common.params.SolrParams params
-
localParams
protected org.apache.solr.common.params.SolrParams localParams
-
req
protected SolrQueryRequest 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
protected String stringIncludingLocalParams
-
valFollowedParams
protected boolean valFollowedParams
-
localParamsEnd
protected int localParamsEnd
-
-
Constructor Detail
-
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 part of the query string specific to this parserlocalParams
- The set of parameters that are specific to this QParser. See https://solr.apache.org/guide/solr/latest/query-guide/local-params.htmlparams
- The rest of theSolrParams
req
- The originalSolrQueryRequest
.
-
-
Method Detail
-
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
public abstract org.apache.lucene.search.Query parse() throws SyntaxError
Create and return theQuery
object represented byqstr
. Null MAY be returned to signify there was no input (e.g. no query string) to parse.- Throws:
SyntaxError
- See Also:
getQuery()
-
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
public SolrQueryRequest getReq()
-
setReq
public void setReq(SolrQueryRequest req)
-
getString
public String getString()
-
setString
public void setString(String s)
-
getQuery
public org.apache.lucene.search.Query getQuery() throws SyntaxError
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
-
subQuery
public QParser subQuery(String q, String defaultType) throws SyntaxError
Create a new QParser for parsing an embedded sub-query- 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 org.apache.lucene.search.Query getHighlightQuery() throws SyntaxError
- Throws:
SyntaxError
-
addDebugInfo
public void addDebugInfo(org.apache.solr.common.util.NamedList<Object> debugInfo)
-
getParser
public static QParser getParser(String qstr, SolrQueryRequest req) throws SyntaxError
Create aQParser
to 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}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 aQParser
to parseqstr
using 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 aQParser
to parseqstr
using theparserName
parser, 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=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.- 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.
-
-