Add a totalHits field on finite pagination return

This commit is contained in:
ManyTheFish 2022-07-20 16:44:09 +02:00
parent 0fa5c9b515
commit e9d493c052

View File

@ -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 {