mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
Hard limit the number of results returned by a search
This commit is contained in:
parent
381e98053f
commit
405af09fc8
@ -34,6 +34,10 @@ pub const fn default_crop_length() -> usize {
|
|||||||
DEFAULT_CROP_LENGTH
|
DEFAULT_CROP_LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The maximimum number of results that the engine
|
||||||
|
/// will be able to return in one search call.
|
||||||
|
pub const HARD_RESULT_LIMIT: usize = 1000;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone, PartialEq)]
|
#[derive(Deserialize, Debug, Clone, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct SearchQuery {
|
pub struct SearchQuery {
|
||||||
@ -124,6 +128,8 @@ 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