mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
250: Add the limit field to http-ui r=Kerollmops a=irevoire 251: Fix the limit r=Kerollmops a=irevoire There was no check on the limit and thus if a user specified a very large number this line could cause a panic. Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
634201244c
@ -687,6 +687,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
filters: Option<String>,
|
||||
facet_filters: Option<Vec<UntaggedEither<Vec<String>, String>>>,
|
||||
facet_distribution: Option<bool>,
|
||||
limit: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@ -739,6 +740,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
search.filter(condition);
|
||||
}
|
||||
|
||||
if let Some(limit) = query.limit {
|
||||
search.limit(limit);
|
||||
}
|
||||
|
||||
let SearchResult { matching_words, candidates, documents_ids } =
|
||||
search.execute().unwrap();
|
||||
|
||||
|
@ -162,7 +162,7 @@ impl<'a> Search<'a> {
|
||||
let mut offset = self.offset;
|
||||
let mut initial_candidates = RoaringBitmap::new();
|
||||
let mut excluded_candidates = RoaringBitmap::new();
|
||||
let mut documents_ids = Vec::with_capacity(self.limit);
|
||||
let mut documents_ids = Vec::new();
|
||||
|
||||
while let Some(FinalResult { candidates, bucket_candidates, .. }) =
|
||||
criteria.next(&excluded_candidates)?
|
||||
|
Loading…
Reference in New Issue
Block a user