mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
if we have no rtree we return all other provided documents
This commit is contained in:
parent
a84f3a8b31
commit
3fc145c254
@ -142,8 +142,9 @@ where
|
||||
Some((head, tail))
|
||||
}
|
||||
|
||||
/// Return the distance between two points in meters.
|
||||
fn distance_between_two_points(a: &[f64; 2], b: &[f64; 2]) -> f64 {
|
||||
/// Return the distance between two points in meters. Each points are composed of two f64,
|
||||
/// one latitude and one longitude.
|
||||
pub fn distance_between_two_points(a: &[f64; 2], b: &[f64; 2]) -> f64 {
|
||||
let a = haversine::Location { latitude: a[0], longitude: a[1] };
|
||||
let b = haversine::Location { latitude: b[0], longitude: b[1] };
|
||||
|
||||
|
@ -45,11 +45,7 @@ impl<'t> 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() {
|
||||
Some(rtree) => rtree,
|
||||
None => return Ok(None),
|
||||
};
|
||||
let rtree = self.rtree.as_ref();
|
||||
|
||||
loop {
|
||||
match self.candidates.next() {
|
||||
@ -92,8 +88,12 @@ impl Criterion for Geo<'_> {
|
||||
continue;
|
||||
}
|
||||
self.allowed_candidates = &candidates - params.excluded_candidates;
|
||||
self.candidates =
|
||||
geo_point(rtree, self.allowed_candidates.clone(), self.point);
|
||||
self.candidates = match rtree {
|
||||
Some(rtree) => {
|
||||
geo_point(rtree, self.allowed_candidates.clone(), self.point)
|
||||
}
|
||||
None => Box::new(std::iter::empty()),
|
||||
};
|
||||
}
|
||||
None => return Ok(None),
|
||||
},
|
||||
|
@ -312,7 +312,7 @@ impl<'t> CriteriaBuilder<'t> {
|
||||
)?),
|
||||
AscDescName::Desc(Member::Geo(_point)) => {
|
||||
return Err(UserError::InvalidSortName {
|
||||
name: "Sorting in descending order is currently not supported for the geosearch".to_string(),
|
||||
name: "sorting in descending order is not supported for the geosearch".to_string(),
|
||||
})?
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user