mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-29 09:39:58 +00:00
Apply suggestions from code review
Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
use std::iter;
|
||||
|
||||
use roaring::RoaringBitmap;
|
||||
use rstar::RTree;
|
||||
|
||||
@ -23,7 +25,7 @@ impl<'t> Geo<'t> {
|
||||
parent: Box<dyn Criterion + 't>,
|
||||
point: [f64; 2],
|
||||
) -> Result<Self> {
|
||||
let candidates = Box::new(std::iter::empty());
|
||||
let candidates = Box::new(iter::empty());
|
||||
let allowed_candidates = index.geo_faceted_documents_ids(rtxn)?;
|
||||
let bucket_candidates = RoaringBitmap::new();
|
||||
let rtree = index.geo_rtree(rtxn)?;
|
||||
@ -41,7 +43,7 @@ impl<'t> Geo<'t> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'t> Criterion for Geo<'t> {
|
||||
impl Criterion for Geo<'_> {
|
||||
fn next(&mut self, params: &mut CriterionParameters) -> Result<Option<CriterionResult>> {
|
||||
// if there is no rtree we have nothing to returns
|
||||
let rtree = match self.rtree.as_ref() {
|
||||
@ -108,7 +110,7 @@ fn geo_point(
|
||||
let results = rtree
|
||||
.nearest_neighbor_iter(&point)
|
||||
.filter_map(move |point| candidates.contains(point.data).then(|| point.data))
|
||||
.map(|id| std::iter::once(id).collect::<RoaringBitmap>())
|
||||
.map(|id| iter::once(id).collect::<RoaringBitmap>())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Box::new(results.into_iter())
|
||||
|
@ -311,7 +311,9 @@ impl<'t> CriteriaBuilder<'t> {
|
||||
point.clone(),
|
||||
)?),
|
||||
AscDescName::Desc(Member::Geo(_point)) => {
|
||||
return Err(UserError::InvalidSortName { name: "Sorting in descending order is currently not supported for the geosearch".to_string() })?
|
||||
return Err(UserError::InvalidSortName {
|
||||
name: "Sorting in descending order is currently not supported for the geosearch".to_string(),
|
||||
})?
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user