mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
Limit the number of elements after reversing it
This commit is contained in:
parent
9d966a28d3
commit
0e5609d40e
@ -177,8 +177,12 @@ impl<'a> Search<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
docids_values.sort_unstable_by_key(|(_, value)| *value);
|
docids_values.sort_unstable_by_key(|(_, value)| *value);
|
||||||
let iter = docids_values.into_iter().map(|(id, _)| id).take(limit);
|
let iter = docids_values.into_iter().map(|(id, _)| id);
|
||||||
if ascending { Ok(iter.collect()) } else { Ok(iter.rev().collect()) }
|
if ascending {
|
||||||
|
Ok(iter.take(limit).collect())
|
||||||
|
} else {
|
||||||
|
Ok(iter.rev().take(limit).collect())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let facet_fn = if ascending {
|
let facet_fn = if ascending {
|
||||||
FacetIter::<f64, FacetLevelValueF64Codec>::new
|
FacetIter::<f64, FacetLevelValueF64Codec>::new
|
||||||
@ -208,8 +212,12 @@ impl<'a> Search<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
docids_values.sort_unstable_by_key(|(_, value)| *value);
|
docids_values.sort_unstable_by_key(|(_, value)| *value);
|
||||||
let iter = docids_values.into_iter().map(|(id, _)| id).take(limit);
|
let iter = docids_values.into_iter().map(|(id, _)| id);
|
||||||
if ascending { Ok(iter.collect()) } else { Ok(iter.rev().collect()) }
|
if ascending {
|
||||||
|
Ok(iter.take(limit).collect())
|
||||||
|
} else {
|
||||||
|
Ok(iter.rev().take(limit).collect())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let facet_fn = if ascending {
|
let facet_fn = if ascending {
|
||||||
FacetIter::<i64, FacetLevelValueI64Codec>::new
|
FacetIter::<i64, FacetLevelValueI64Codec>::new
|
||||||
|
Loading…
Reference in New Issue
Block a user