mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-05 04:28:55 +01:00
Make search returns 0 hits when pages is set to 0
This commit is contained in:
parent
dfa70e47f7
commit
e35ea2ad55
@ -152,13 +152,16 @@ impl Index {
|
||||
search.exhaustive_number_hits(is_finite_pagination);
|
||||
|
||||
let (offset, limit) = if is_finite_pagination {
|
||||
let offset = min(
|
||||
query.hits_per_page * (query.page.saturating_sub(1)),
|
||||
max_total_hits,
|
||||
);
|
||||
let limit = min(query.hits_per_page, max_total_hits.saturating_sub(offset));
|
||||
match query.page.checked_sub(1) {
|
||||
Some(page) => {
|
||||
let offset = min(query.hits_per_page * page, max_total_hits);
|
||||
let limit = min(query.hits_per_page, max_total_hits.saturating_sub(offset));
|
||||
|
||||
(offset, limit)
|
||||
(offset, limit)
|
||||
}
|
||||
// page 0 returns 0 hits
|
||||
None => (0, 0),
|
||||
}
|
||||
} else {
|
||||
let offset = min(query.offset.unwrap_or(0), max_total_hits);
|
||||
let limit = min(
|
||||
|
Loading…
Reference in New Issue
Block a user