public class GroupingSearch extends Object
| Constructor and Description |
|---|
GroupingSearch(GroupSelector<?> groupSelector)
Constructs a
GroupingSearch instance that groups documents using a GroupSelector |
GroupingSearch(Query groupEndDocs)
Constructor for grouping documents by doc block.
|
GroupingSearch(String groupField)
Constructs a
GroupingSearch instance that groups documents by index terms using DocValues. |
GroupingSearch(ValueSource groupFunction,
Map<?,?> valueSourceContext)
Constructs a
GroupingSearch instance that groups documents by function using a ValueSource
instance. |
| Modifier and Type | Method and Description |
|---|---|
GroupingSearch |
disableCaching()
Disables any enabled cache.
|
Bits |
getAllGroupHeads()
Returns the matching group heads if
setAllGroupHeads(boolean) was set to true or an empty bit set. |
<T> Collection<T> |
getAllMatchingGroups()
If
setAllGroups(boolean) was set to true then all matching groups are returned, otherwise
an empty collection is returned. |
protected TopGroups<?> |
groupByDocBlock(IndexSearcher searcher,
Query query,
int groupOffset,
int groupLimit) |
protected TopGroups |
groupByFieldOrFunction(IndexSearcher searcher,
Query query,
int groupOffset,
int groupLimit) |
<T> TopGroups<T> |
search(IndexSearcher searcher,
Query query,
int groupOffset,
int groupLimit)
Executes a grouped search.
|
GroupingSearch |
setAllGroupHeads(boolean allGroupHeads)
Whether to compute all group heads (most relevant document per group) matching the query.
|
GroupingSearch |
setAllGroups(boolean allGroups)
Whether to also compute all groups matching the query.
|
GroupingSearch |
setCaching(int maxDocsToCache,
boolean cacheScores)
Enables caching for the second pass search.
|
GroupingSearch |
setCachingInMB(double maxCacheRAMMB,
boolean cacheScores)
Enables caching for the second pass search.
|
GroupingSearch |
setGroupDocsLimit(int groupDocsLimit)
Specifies the number of documents to return inside a group from the specified groupDocsOffset.
|
GroupingSearch |
setGroupDocsOffset(int groupDocsOffset)
Specifies the offset for documents inside a group.
|
GroupingSearch |
setGroupSort(Sort groupSort)
Specifies how groups are sorted.
|
GroupingSearch |
setIncludeMaxScore(boolean includeMaxScore)
Whether to include the score of the most relevant document per group.
|
GroupingSearch |
setSortWithinGroup(Sort sortWithinGroup)
Specified how documents inside a group are sorted.
|
public GroupingSearch(String groupField)
GroupingSearch instance that groups documents by index terms using DocValues.
The group field can only have one token per document. This means that the field must not be analysed.groupField - The name of the field to group by.public GroupingSearch(GroupSelector<?> groupSelector)
GroupingSearch instance that groups documents using a GroupSelectorgroupSelector - a GroupSelector that defines groups for this GroupingSearchpublic GroupingSearch(ValueSource groupFunction, Map<?,?> valueSourceContext)
GroupingSearch instance that groups documents by function using a ValueSource
instance.groupFunction - The function to group by specified as ValueSourcevalueSourceContext - The context of the specified groupFunctionpublic GroupingSearch(Query groupEndDocs)
groupEndDocs - The query that marks the last document in all doc blockspublic <T> TopGroups<T> search(IndexSearcher searcher, Query query, int groupOffset, int groupLimit) throws IOException
searcher - The IndexSearcher instance to execute the grouped search on.query - The query to execute with the groupinggroupOffset - The group offsetgroupLimit - The number of groups to return from the specified group offsetTopGroups instanceIOException - If any I/O related errors occurprotected TopGroups groupByFieldOrFunction(IndexSearcher searcher, Query query, int groupOffset, int groupLimit) throws IOException
IOExceptionprotected TopGroups<?> groupByDocBlock(IndexSearcher searcher, Query query, int groupOffset, int groupLimit) throws IOException
IOExceptionpublic GroupingSearch setCachingInMB(double maxCacheRAMMB, boolean cacheScores)
maxCacheRAMMB - The maximum amount in MB the cache is allowed to holdcacheScores - Whether to cache the scoresthispublic GroupingSearch setCaching(int maxDocsToCache, boolean cacheScores)
maxDocsToCache - The maximum number of documents the cache is allowed to holdcacheScores - Whether to cache the scoresthispublic GroupingSearch disableCaching()
thispublic GroupingSearch setGroupSort(Sort groupSort)
Sort.RELEVANCE.groupSort - The sort for the groups.thispublic GroupingSearch setSortWithinGroup(Sort sortWithinGroup)
Sort.RELEVANCE.sortWithinGroup - The sort for documents inside a groupthispublic GroupingSearch setGroupDocsOffset(int groupDocsOffset)
groupDocsOffset - The offset for documents inside athispublic GroupingSearch setGroupDocsLimit(int groupDocsLimit)
groupDocsLimit - The number of documents to return inside a groupthispublic GroupingSearch setIncludeMaxScore(boolean includeMaxScore)
includeMaxScore - Whether to include the score of the most relevant document per groupthispublic GroupingSearch setAllGroups(boolean allGroups)
When grouping by doc block the number of groups are automatically included in the TopGroups and this
option doesn't have any influence.
allGroups - to also compute all groups matching the querythispublic <T> Collection<T> getAllMatchingGroups()
setAllGroups(boolean) was set to true then all matching groups are returned, otherwise
an empty collection is returned.T - The group value type. This can be a BytesRef or a MutableValue instance. If grouping
by doc block this the group value is always null.public GroupingSearch setAllGroupHeads(boolean allGroupHeads)
This feature isn't enabled when grouping by doc block.
allGroupHeads - Whether to compute all group heads (most relevant document per group) matching the querythispublic Bits getAllGroupHeads()
setAllGroupHeads(boolean) was set to true or an empty bit set.setAllGroupHeads(boolean) was set to true or an empty bit setCopyright © 2000-2024 Apache Software Foundation. All Rights Reserved.