Class CollapsingQParserPlugin
- All Implemented Interfaces:
NamedListInitializedPlugin
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 ClassesModifier and TypeClassDescriptionprotected static classAbstract base class for all collapse collectors.protected static classHelper class for dealing with boosted docs, which always get collected (even if there is more then one in a group) and suppress any non-boosted docs from being collected from their group (even if they should be based on the group head selectors)static final classstatic classstatic final recordModels all the information about how group head documents should be selectedstatic enumstatic final recordBuilder forCollapsingQParserPlugin.IntFieldValueCollector.protected static classCollapses on an integer field.protected static classCollector for collapsing on int field using min/max of a float field to select group head.protected static classCollector for collapsing on int field using min/max of an integer field to select group head.protected static classCollector for collapsing on int field using a sort spec to select group head.protected static classCollector for collapsing on int field using function query to select group head.protected static classstatic enumstatic final recordBuilder forCollapsingQParserPlugin.OrdFieldValueCollector.protected static classCollapse on Ordinal value field.protected static classCollector for collapsing on ordinal using min/max of a float field to select group head.protected static classCollector for collapsing on ordinal using min/max of an int field to select group head.protected static classCollector for collapsing on ordinal using min/max of a long field to select group head.protected static classCollector for collapsing on ordinal using the first document according to a complex sort as the group head.protected static classCollector for collapsing on ordinal using min/max of a value source function to select group head. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringIf elevation is used in combination with the collapse query parser, we can define that we only want to return the representative and not all elevated docs by setting this parameter to false (true by default).static final StringIndicates that values in the collapse field are unique per contiguous block, and a single pass "block based" collapse algorithm can be used.static final Stringstatic final StringFields inherited from class org.apache.solr.search.QParserPlugin
DEFAULT_QTYPE, standardPlugins -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest request) Creates theQParser.static org.apache.lucene.index.LeafReadergetTopFieldCacheReader(SolrIndexSearcher searcher, String collapseField) This forces the use of the top level field cache for String fields.static org.apache.lucene.search.SortrewriteSort(SortSpec sortSpec, org.apache.lucene.search.IndexSearcher searcher) Helper method for rewriting the Sort associated with a SortSpec.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.util.plugin.NamedListInitializedPlugin
init
-
Field Details
-
NAME
- See Also:
-
HINT_TOP_FC
- See Also:
-
HINT_BLOCK
Indicates that values in the collapse field are unique per contiguous block, and a single pass "block based" collapse algorithm can be used. This behavior is the default for collapsing on the_root_field, but may also be enabled for other fields that have the same characteristics. This hint will be ignored if other options prevent the use of this single pass approach (notable: nullPolicy=collapse)Do NOT use this hint if the index is not laid out such that each unique value in the collapse field is garuntteed to only exist in one contiguous block, otherwise the results of the collapse filter will include more then one document per collapse value.
- See Also:
-
COLLECT_ELEVATED_DOCS_WHEN_COLLAPSING
If elevation is used in combination with the collapse query parser, we can define that we only want to return the representative and not all elevated docs by setting this parameter to false (true by default).
-
-
Constructor Details
-
CollapsingQParserPlugin
public CollapsingQParserPlugin()
-
-
Method Details
-
createParser
public QParser createParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest request) Description copied from class:QParserPluginCreates theQParser.- Specified by:
createParserin classQParserPlugin- See Also:
-
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
-