From 75b491d501617f3974da968c2328649bfb0900e5 Mon Sep 17 00:00:00 2001 From: IgorRodchenkov Date: Sun, 23 Jun 2024 09:27:02 -0400 Subject: [PATCH] Fixed total num. hits in search results. --- src/main/java/cpath/service/IndexImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cpath/service/IndexImpl.java b/src/main/java/cpath/service/IndexImpl.java index a2ef1c79..2365e0fb 100644 --- a/src/main/java/cpath/service/IndexImpl.java +++ b/src/main/java/cpath/service/IndexImpl.java @@ -180,7 +180,7 @@ private SearchResponse transform(Query query, IndexSearcher searcher, TopDocs to } SearchResponse response = new SearchResponse(); response.setMaxHitsPerPage(getMaxHitsPerPage()); - long numTotalHits = topDocs.totalHits.value; //todo: call searcher.count(q) instead or it's the same? + long numTotalHits = searcher.count(query); response.setNumHits(numTotalHits); List hits = response.getSearchHit();//empty list to be filled from top docs assert hits!=null && hits.isEmpty();