Interface TotalHitsAwareCollector
Collector
to be informed of the total number of hits.
This is only recognised by the LuceneSearchProvider
methods
com.atlassian.jira.issue.search.providers.LuceneSearchProvider#searchAndSort(com.atlassian.query.Query, com.atlassian.jira.user.ApplicationUser, org.apache.lucene.search.Collector, com.atlassian.jira.web.bean.PagerFilter)
com.atlassian.jira.issue.search.providers.LuceneSearchProvider#searchAndSort(com.atlassian.query.Query, com.atlassian.crowd.embedded.api.User, org.apache.lucene.search.Collector, com.atlassian.jira.web.bean.PagerFilter)
com.atlassian.jira.issue.search.providers.LuceneSearchProvider#searchAndSortOverrideSecurity(com.atlassian.query.Query, com.atlassian.crowd.embedded.api.User, org.apache.lucene.search.Collector, com.atlassian.jira.web.bean.PagerFilter)
com.atlassian.jira.issue.search.providers.LuceneSearchProvider#searchAndSortOverrideSecurity(com.atlassian.query.Query, com.atlassian.jira.user.ApplicationUser, org.apache.lucene.search.Collector, com.atlassian.jira.web.bean.PagerFilter)
If you wish to search for the top 500 results, but also know the total hits.
collector = new MyCollector() // Implementing TotalHitsAwareCollector
PagerFilter filter = new PagerFilter(1, 500);
searchProvider.searchAndSort(parseResult.getQuery(), user, collector, filter);
This will call setTotalHits(int x) on your collector.
- Since:
- v6.0.1
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
Get the total hits.void
setTotalHits
(int totalHits) Set the total hits.
-
Method Details
-
setTotalHits
void setTotalHits(int totalHits) Set the total hits. This may be larger thanPagerFilter.getMax()
requested when the search is invoked. There is no ordering guaranteed between calls to this method and calls toCollector#collect(int)
. This method will be called even if collect() is not (e.g. there are no results).- Parameters:
totalHits
-
-
getTotalHits
default int getTotalHits()Get the total hits.- Since:
- v7.2
-