Package org.apache.solr.search
Class Grouping.Command<T>
- java.lang.Object
-
- org.apache.solr.search.Grouping.Command<T>
-
- Direct Known Subclasses:
Grouping.CommandField,Grouping.CommandFunc,Grouping.CommandQuery
- Enclosing class:
- Grouping
public abstract class Grouping.Command<T> extends Object
General group command. A group command is responsible for creating the first and second pass collectors. A group command is also responsible for creating the response structure.Note: Maybe the creating the response structure should be done in something like a ReponseBuilder??? Warning NOT thread save!
-
-
Field Summary
Fields Modifier and Type Field Description intdocsPerGroupGrouping.FormatformatintgroupOffsetorg.apache.lucene.search.SortgroupSortStringkeybooleanmainintnumGroupsintoffsetGrouping.TotalCounttotalCountorg.apache.lucene.search.SortwithinGroupSort
-
Constructor Summary
Constructors Constructor Description Command()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddDocList(org.apache.solr.common.util.NamedList<? super DocList> rsp, org.apache.lucene.search.grouping.GroupDocs<?> groups)protected org.apache.solr.common.util.NamedList<Object>commonResponse()org.apache.lucene.search.grouping.AllGroupHeadsCollector<?>createAllGroupCollector()Returns a collector that is able to return the most relevant document of all groups.protected abstract org.apache.lucene.search.CollectorcreateFirstPassCollector()Returns one or moreCollectorinstances that are needed to perform the first pass search.protected org.apache.lucene.search.CollectorcreateSecondPassCollector()Returns zero or moreCollectorinstances that are needed to perform the second pass search.protected DocListcreateSimpleResponse()protected abstract voidfinish()Performs any necessary post actions to prepare the response.protected DocListgetDocList(org.apache.lucene.search.grouping.GroupDocs<?> groups)abstract intgetMatches()Returns the number of matches for thisCommand.protected IntegergetNumberOfGroups()Returns the number of groups found for thisCommand.protected voidpopulateScoresIfNecessary()protected abstract voidprepare()Prepare thisCommandfor execution.
-
-
-
Field Detail
-
key
public String key
-
withinGroupSort
public org.apache.lucene.search.Sort withinGroupSort
-
groupSort
public org.apache.lucene.search.Sort groupSort
-
docsPerGroup
public int docsPerGroup
-
groupOffset
public int groupOffset
-
numGroups
public int numGroups
-
offset
public int offset
-
format
public Grouping.Format format
-
main
public boolean main
-
totalCount
public Grouping.TotalCount totalCount
-
-
Method Detail
-
prepare
protected abstract void prepare() throws IOExceptionPrepare thisCommandfor execution.- Throws:
IOException- If I/O related errors occur
-
createFirstPassCollector
protected abstract org.apache.lucene.search.Collector createFirstPassCollector() throws IOExceptionReturns one or moreCollectorinstances that are needed to perform the first pass search. If multiple Collectors are returned then these wrapped in aMultiCollector.- Returns:
- one or more
Collectorinstances that are need to perform the first pass search - Throws:
IOException- If I/O related errors occur
-
createSecondPassCollector
protected org.apache.lucene.search.Collector createSecondPassCollector() throws IOExceptionReturns zero or moreCollectorinstances that are needed to perform the second pass search. In the case when noCollectorinstances are creatednullis returned. If multiple Collectors are returned then these wrapped in aMultiCollector.- Returns:
- zero or more
Collectorinstances that are needed to perform the second pass search - Throws:
IOException- If I/O related errors occur
-
createAllGroupCollector
public org.apache.lucene.search.grouping.AllGroupHeadsCollector<?> createAllGroupCollector() throws IOExceptionReturns a collector that is able to return the most relevant document of all groups. Returnsnullif the command doesn't support this type of collector.- Returns:
- a collector that is able to return the most relevant document of all groups.
- Throws:
IOException- If I/O related errors occur
-
finish
protected abstract void finish() throws IOExceptionPerforms any necessary post actions to prepare the response.- Throws:
IOException- If I/O related errors occur
-
getMatches
public abstract int getMatches()
Returns the number of matches for thisCommand.- Returns:
- the number of matches for this
Command
-
getNumberOfGroups
protected Integer getNumberOfGroups()
Returns the number of groups found for thisCommand. If the command doesn't support counting the groupsnullis returned.- Returns:
- the number of groups found for this
Command
-
populateScoresIfNecessary
protected void populateScoresIfNecessary() throws IOException- Throws:
IOException
-
commonResponse
protected org.apache.solr.common.util.NamedList<Object> commonResponse()
-
getDocList
protected DocList getDocList(org.apache.lucene.search.grouping.GroupDocs<?> groups)
-
addDocList
protected void addDocList(org.apache.solr.common.util.NamedList<? super DocList> rsp, org.apache.lucene.search.grouping.GroupDocs<?> groups)
-
createSimpleResponse
protected DocList createSimpleResponse()
-
-