mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-17 08:10:14 +08: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))
|
Some((head, tail))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the distance between two points in meters.
|
/// Return the distance between two points in meters. Each points are composed of two f64,
|
||||||
fn distance_between_two_points(a: &[f64; 2], b: &[f64; 2]) -> 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 a = haversine::Location { latitude: a[0], longitude: a[1] };
|
||||||
let b = haversine::Location { latitude: b[0], longitude: b[1] };
|
let b = haversine::Location { latitude: b[0], longitude: b[1] };
|
||||||
|
|
||||||
|
@ -45,11 +45,7 @@ impl<'t> Geo<'t> {
|
|||||||
|
|
||||||
impl Criterion for Geo<'_> {
|
impl Criterion for Geo<'_> {
|
||||||
fn next(&mut self, params: &mut CriterionParameters) -> Result<Option<CriterionResult>> {
|
fn next(&mut self, params: &mut CriterionParameters) -> Result<Option<CriterionResult>> {
|
||||||
// if there is no rtree we have nothing to returns
|
let rtree = self.rtree.as_ref();
|
||||||
let rtree = match self.rtree.as_ref() {
|
|
||||||
Some(rtree) => rtree,
|
|
||||||
None => return Ok(None),
|
|
||||||
};
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.candidates.next() {
|
match self.candidates.next() {
|
||||||
@ -92,8 +88,12 @@ impl Criterion for Geo<'_> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self.allowed_candidates = &candidates - params.excluded_candidates;
|
self.allowed_candidates = &candidates - params.excluded_candidates;
|
||||||
self.candidates =
|
self.candidates = match rtree {
|
||||||
geo_point(rtree, self.allowed_candidates.clone(), self.point);
|
Some(rtree) => {
|
||||||
|
geo_point(rtree, self.allowed_candidates.clone(), self.point)
|
||||||
|
}
|
||||||
|
None => Box::new(std::iter::empty()),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
},
|
},
|
||||||
|
@ -312,7 +312,7 @@ impl<'t> CriteriaBuilder<'t> {
|
|||||||
)?),
|
)?),
|
||||||
AscDescName::Desc(Member::Geo(_point)) => {
|
AscDescName::Desc(Member::Geo(_point)) => {
|
||||||
return Err(UserError::InvalidSortName {
|
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…
x
Reference in New Issue
Block a user