Skip to content

Commit d3f765c

Browse files
committed
Page computation doesn't fail if query size = 0 - #19
1 parent 84b1edf commit d3f765c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

module/app/com/github/cleverage/elasticsearch/IndexQuery.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,12 @@ private IndexResults<T> toSearchResults(SearchResponse searchResponse) {
311311
pageCurrent = ((int) (from / pageSize))+1;
312312
}
313313

314-
long pageNb = (long)Math.ceil(new BigDecimal(count).divide(new BigDecimal(pageSize), 2, RoundingMode.HALF_UP).doubleValue());
314+
long pageNb;
315+
if (pageSize == 0) {
316+
pageNb = 1;
317+
} else {
318+
pageNb = (long)Math.ceil(new BigDecimal(count).divide(new BigDecimal(pageSize), 2, RoundingMode.HALF_UP).doubleValue());
319+
}
315320

316321
// Return Results
317322
return new IndexResults<T>(count, pageSize, pageCurrent, pageNb, results, facetsResponse);

0 commit comments

Comments
 (0)