From e9d493c0526827a035f50364b51dcec767382b04 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 20 Jul 2022 16:44:09 +0200 Subject: [PATCH] Add a totalHits field on finite pagination return --- meilisearch-lib/src/index/search.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meilisearch-lib/src/index/search.rs b/meilisearch-lib/src/index/search.rs index 0089e8e12..11e038126 100644 --- a/meilisearch-lib/src/index/search.rs +++ b/meilisearch-lib/src/index/search.rs @@ -118,6 +118,7 @@ pub enum HitsInfo { hits_per_page: usize, page: usize, total_pages: usize, + total_hits: usize, }, #[serde(rename_all = "camelCase")] OffsetLimit { @@ -299,8 +300,8 @@ impl Index { HitsInfo::Pagination { hits_per_page, page: offset / hits_per_page + 1, - // TODO @many: estimation for now but we should ask milli to return an exact value total_pages: (number_of_hits + hits_per_page - 1) / query.hits_per_page, + total_hits: number_of_hits, } } else { HitsInfo::OffsetLimit {