Package org.apache.solr.search.join
Class ScoreJoinQParserPlugin
- java.lang.Object
-
- org.apache.solr.search.QParserPlugin
-
- org.apache.solr.search.join.ScoreJoinQParserPlugin
-
- All Implemented Interfaces:
AutoCloseable
,SolrInfoBean
,SolrMetricProducer
,NamedListInitializedPlugin
public class ScoreJoinQParserPlugin extends QParserPlugin
Create a query-time join query with scoring. It just callsJoinUtil.createJoinQuery(String, boolean, String, Query, org.apache.lucene.search.IndexSearcher, ScoreMode)
. It runs subordinate query and collects values of "from" field and scores, then it lookups these collected values in "to" field, and yields aggregated scores. Local parameters are similar toJoinQParserPlugin
{!join} This plugin doesn't have its own name, and is called by specifying local parameter{!join score=...}...
. Note: this parser is invoked even if you specifyscore=none
.
Example:q={!join from=manu_id_s to=id score=total}foo
- from - "foreign key" field name to collect values while enumerating subordinate query
(denoted as
foo
in example above). it's better to have this field declared astype="string" docValues="true"
. note: if docValues are not enabled for this field, it will work anyway, but it costs some memory forUninvertingReader
. Also, numeric doc values are not supported until LUCENE-5868. Thus, it only supportsDocValuesType.SORTED
,DocValuesType.SORTED_SET
,DocValuesType.BINARY
. - fromIndex - optional parameter, a core name where subordinate query should run (and
from
values are collected) rather than current core.
Example:q={!join from=manu_id_s to=id score=total fromIndex=products}foo
- to - "primary key" field name which is searched for values collected from subordinate
query. it should be declared as
indexed="true"
. Now it's treated as a single value field. - score - one of
ScoreMode
:none,avg,total,max,min
. Capital case is also accepted.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHECK_ROUTER_FIELD
static String
SCORE
static String
USE_CROSSCOLLECTION
-
Fields inherited from class org.apache.solr.search.QParserPlugin
DEFAULT_QTYPE, standardPlugins
-
-
Constructor Summary
Constructors Constructor Description ScoreJoinQParserPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.lucene.search.Query
createJoinQuery(org.apache.lucene.search.Query subQuery, String fromField, String toField, org.apache.lucene.search.join.ScoreMode scoreMode)
A helper method for other plugins to create single-core JoinQueriesQParser
createParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)
return aQParser
static String
getCoreName(String fromIndex, CoreContainer container, SolrCore toCore, String toField, String fromField, org.apache.solr.common.params.SolrParams localParams)
Returns a String with the name of a core.-
Methods inherited from class org.apache.solr.search.QParserPlugin
getCategory, getDescription, getName, getSolrMetricsContext, initializeMetrics
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.util.plugin.NamedListInitializedPlugin
init
-
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
-
-
-
Field Detail
-
USE_CROSSCOLLECTION
public static final String USE_CROSSCOLLECTION
- See Also:
- Constant Field Values
-
SCORE
public static final String SCORE
- See Also:
- Constant Field Values
-
CHECK_ROUTER_FIELD
public static final String CHECK_ROUTER_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
createParser
public QParser createParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)
Description copied from class:QParserPlugin
return aQParser
- Specified by:
createParser
in classQParserPlugin
-
getCoreName
public static String getCoreName(String fromIndex, CoreContainer container, SolrCore toCore, String toField, String fromField, org.apache.solr.common.params.SolrParams localParams)
Returns a String with the name of a core.This method searches the core with fromIndex name in the core's container. If fromIndex isn't the name of a collection or alias it returns fromIndex without changes. If fromIndex is the name of an alias but the alias points to multiple collections it throws SolrException.ErrorCode.BAD_REQUEST because multiple shards not yet supported.
- Parameters:
fromIndex
- name of the indexcontainer
- the core container for searching the core with fromIndex name or aliastoCore
- core which it joins to ie executing this requesttoField
- to side fieldfromField
- from side fieldlocalParams
- local params for this qparser invocation- Returns:
- the string with name of core
-
createJoinQuery
public static org.apache.lucene.search.Query createJoinQuery(org.apache.lucene.search.Query subQuery, String fromField, String toField, org.apache.lucene.search.join.ScoreMode scoreMode)
A helper method for other plugins to create single-core JoinQueries- Parameters:
subQuery
- the query to define the starting set of documents on the "left side" of the joinfromField
- "left side" field name to use in the jointoField
- "right side" field name to use in the joinscoreMode
- the score statistic to produce while joining- See Also:
JoinQParserPlugin.createJoinQuery(Query, String, String, String)
-
-