mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08: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);
|
search.exhaustive_number_hits(is_finite_pagination);
|
||||||
|
|
||||||
let (offset, limit) = if is_finite_pagination {
|
let (offset, limit) = if is_finite_pagination {
|
||||||
let offset = min(
|
match query.page.checked_sub(1) {
|
||||||
query.hits_per_page * (query.page.saturating_sub(1)),
|
Some(page) => {
|
||||||
max_total_hits,
|
let offset = min(query.hits_per_page * page, max_total_hits);
|
||||||
);
|
let limit = min(query.hits_per_page, max_total_hits.saturating_sub(offset));
|
||||||
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 {
|
} else {
|
||||||
let offset = min(query.offset.unwrap_or(0), max_total_hits);
|
let offset = min(query.offset.unwrap_or(0), max_total_hits);
|
||||||
let limit = min(
|
let limit = min(
|
||||||
|
Loading…
Reference in New Issue
Block a user