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:
Shay Banon 2014-01-08 18:28:46 +01:00
parent 7ae4d101ab
commit e9f5e5a8b3
1 changed files with 1 additions and 5 deletions

View File

@ -104,12 +104,8 @@ public class QueryPhase implements SearchPhase {
TopDocs topDocs; TopDocs topDocs;
int numDocs = searchContext.from() + searchContext.size(); 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(); TotalHitCountCollector collector = new TotalHitCountCollector();
searchContext.searcher().search(query, collector); searchContext.searcher().search(query, collector);
topDocs = new TopDocs(collector.getTotalHits(), Lucene.EMPTY_SCORE_DOCS, 0); topDocs = new TopDocs(collector.getTotalHits(), Lucene.EMPTY_SCORE_DOCS, 0);