Merge pull request #50 from meilisearch/fix-asc-desc-criterion

Fix the Asc/Desc criteria
This commit is contained in:
Clément Renault 2020-12-13 11:59:11 +01:00 committed by GitHub
commit cd5605bb86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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