From e9f5e5a8b3bbb4ae4b99c766aa50ccbb6bbfc4a6 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 8 Jan 2014 18:28:46 +0100 Subject: [PATCH] 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... --- .../java/org/elasticsearch/search/query/QueryPhase.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/query/QueryPhase.java b/src/main/java/org/elasticsearch/search/query/QueryPhase.java index 576a2a6820a..0e6aacd00a8 100644 --- a/src/main/java/org/elasticsearch/search/query/QueryPhase.java +++ b/src/main/java/org/elasticsearch/search/query/QueryPhase.java @@ -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);