when specifying size 0, just use the total hits collector in query phase
no need the (old) hack of setting the size to 1 anymore really...
This commit is contained in:
parent
7ae4d101ab
commit
e9f5e5a8b3
|
@ -104,12 +104,8 @@ public class QueryPhase implements SearchPhase {
|
|||
|
||||
TopDocs topDocs;
|
||||
int numDocs = searchContext.from() + searchContext.size();
|
||||
if (numDocs == 0) {
|
||||
// if 0 was asked, change it to 1 since 0 is not allowed
|
||||
numDocs = 1;
|
||||
}
|
||||
|
||||
if (searchContext.searchType() == SearchType.COUNT) {
|
||||
if (searchContext.searchType() == SearchType.COUNT || numDocs == 0) {
|
||||
TotalHitCountCollector collector = new TotalHitCountCollector();
|
||||
searchContext.searcher().search(query, collector);
|
||||
topDocs = new TopDocs(collector.getTotalHits(), Lucene.EMPTY_SCORE_DOCS, 0);
|
||||
|
|
Loading…
Reference in New Issue