mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
Make sure that offsets are clamped too
This commit is contained in:
parent
405af09fc8
commit
8bc6e8dcf9
@ -1,3 +1,4 @@
|
|||||||
|
use std::cmp::min;
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
@ -101,8 +102,13 @@ impl Index {
|
|||||||
search.query(query);
|
search.query(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
search.limit(query.limit);
|
// Make sure that a user can't get more documents than the hard limit,
|
||||||
search.offset(query.offset.unwrap_or_default());
|
// we align that on the offset too.
|
||||||
|
let offset = min(query.offset.unwrap_or(0), HARD_RESULT_LIMIT);
|
||||||
|
let limit = min(query.limit, HARD_RESULT_LIMIT.saturating_sub(offset));
|
||||||
|
|
||||||
|
search.offset(offset);
|
||||||
|
search.limit(limit);
|
||||||
|
|
||||||
if let Some(ref filter) = query.filter {
|
if let Some(ref filter) = query.filter {
|
||||||
if let Some(facets) = parse_filter(filter)? {
|
if let Some(facets) = parse_filter(filter)? {
|
||||||
@ -128,8 +134,6 @@ impl Index {
|
|||||||
..
|
..
|
||||||
} = search.execute()?;
|
} = search.execute()?;
|
||||||
|
|
||||||
let documents_ids: Vec<_> = documents_ids.into_iter().take(HARD_RESULT_LIMIT).collect();
|
|
||||||
|
|
||||||
let fields_ids_map = self.fields_ids_map(&rtxn).unwrap();
|
let fields_ids_map = self.fields_ids_map(&rtxn).unwrap();
|
||||||
|
|
||||||
let displayed_ids = self
|
let displayed_ids = self
|
||||||
|
Loading…
Reference in New Issue
Block a user