mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Optimize facet sort
5 to 10x speedup
This commit is contained in:
parent
4534dc2cab
commit
340d9e6edc
2 changed files with 256 additions and 60 deletions
|
@ -1558,19 +1558,32 @@ fn retrieve_documents<S: AsRef<str>>(
|
|||
})?
|
||||
}
|
||||
|
||||
let mut facet_sort = None;
|
||||
if let Some(sort) = sort_criteria {
|
||||
candidates = recursive_facet_sort(index, &rtxn, &sort, candidates)?;
|
||||
facet_sort = Some(recursive_facet_sort(index, &rtxn, &sort, &candidates)?)
|
||||
}
|
||||
|
||||
let (it, number_of_documents) = {
|
||||
let (it, number_of_documents) = if let Some(facet_sort) = &facet_sort {
|
||||
let number_of_documents = candidates.len();
|
||||
let iter = facet_sort.iter()?;
|
||||
(
|
||||
itertools::Either::Left(some_documents(
|
||||
index,
|
||||
&rtxn,
|
||||
iter.map(|d| d.unwrap()).skip(offset).take(limit),
|
||||
retrieve_vectors,
|
||||
)?),
|
||||
number_of_documents,
|
||||
)
|
||||
} else {
|
||||
let number_of_documents = candidates.len();
|
||||
(
|
||||
some_documents(
|
||||
itertools::Either::Right(some_documents(
|
||||
index,
|
||||
&rtxn,
|
||||
candidates.into_iter().skip(offset).take(limit),
|
||||
retrieve_vectors,
|
||||
)?,
|
||||
)?),
|
||||
number_of_documents,
|
||||
)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue