Class CollapsingQParserPlugin
- java.lang.Object
-
- org.apache.solr.search.QParserPlugin
-
- org.apache.solr.search.CollapsingQParserPlugin
-
- All Implemented Interfaces:
SolrInfoBean
,NamedListInitializedPlugin
public class CollapsingQParserPlugin extends QParserPlugin
The CollapsingQParserPlugin is a PostFilter that performs field collapsing. This is a high performance alternative to standard Solr field collapsing (with ngroups) when the number of distinct groups in the result set is high.Sample syntax:
Collapse based on the highest scoring document:
fq=(!collapse field=field_name}
Collapse based on the min value of a numeric field:
fq={!collapse field=field_name min=field_name}
Collapse based on the max value of a numeric field:
fq={!collapse field=field_name max=field_name}
Collapse with a null policy:
fq={!collapse field=field_name nullPolicy=nullPolicy}
There are three null policies:
ignore : removes docs with a null value in the collapse field (default).
expand : treats each doc with a null value in the collapse field as a separate group.
collapse : collapses all docs with a null value into a single group using either highest score, or min/max.The CollapsingQParserPlugin fully supports the QueryElevationComponent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CollapsingQParserPlugin.CollapseScore
static class
CollapsingQParserPlugin.CollapsingPostFilter
static class
CollapsingQParserPlugin.GroupHeadSelector
Models all the information about how group head documents should be selectedstatic class
CollapsingQParserPlugin.GroupHeadSelectorType
-
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
HINT_MULTI_DOCVALUES
static String
HINT_TOP_FC
static String
NAME
static String
NULL_COLLAPSE
static String
NULL_EXPAND
static String
NULL_IGNORE
-
Fields inherited from class org.apache.solr.search.QParserPlugin
DEFAULT_QTYPE, standardPlugins
-
-
Constructor Summary
Constructors Constructor Description CollapsingQParserPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description QParser
createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest request)
return aQParser
static org.apache.lucene.index.LeafReader
getTopFieldCacheReader(SolrIndexSearcher searcher, String collapseField)
This forces the use of the top level field cache for String fields.static org.apache.lucene.search.Sort
rewriteSort(SortSpec sortSpec, org.apache.lucene.search.IndexSearcher searcher)
Helper method for rewriting the Sort associated with a SortSpec.-
Methods inherited from class org.apache.solr.search.QParserPlugin
getCategory, getDescription, getMetricNames, getName, init
-
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.core.SolrInfoBean
getMetricRegistry, getMetricsSnapshot, registerMetricName
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
NULL_COLLAPSE
public static final String NULL_COLLAPSE
- See Also:
- Constant Field Values
-
NULL_IGNORE
public static final String NULL_IGNORE
- See Also:
- Constant Field Values
-
NULL_EXPAND
public static final String NULL_EXPAND
- See Also:
- Constant Field Values
-
HINT_TOP_FC
public static final String HINT_TOP_FC
- See Also:
- Constant Field Values
-
HINT_MULTI_DOCVALUES
public static final String HINT_MULTI_DOCVALUES
- See Also:
- Constant Field Values
-
-
Method Detail
-
createParser
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest request)
Description copied from class:QParserPlugin
return aQParser
- Specified by:
createParser
in classQParserPlugin
-
getTopFieldCacheReader
public static org.apache.lucene.index.LeafReader getTopFieldCacheReader(SolrIndexSearcher searcher, String collapseField)
This forces the use of the top level field cache for String fields. This is VERY fast at query time but slower to warm and causes insanity.
-
rewriteSort
public static org.apache.lucene.search.Sort rewriteSort(SortSpec sortSpec, org.apache.lucene.search.IndexSearcher searcher) throws IOException
Helper method for rewriting the Sort associated with a SortSpec. Handles the special case default of relevancy sort (ie: a SortSpec w/null Sort object)- Throws:
IOException
-
-