mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
re-implement the geosearch
This commit is contained in:
parent
7cd9109e2f
commit
3942b3732f
@ -253,36 +253,7 @@ impl<'a> Filter<'a> {
|
|||||||
rtxn, index, numbers_db, strings_db, field_id, &operator,
|
rtxn, index, numbers_db, strings_db, field_id, &operator,
|
||||||
)?;
|
)?;
|
||||||
return Ok((all_numbers_ids | all_strings_ids) - docids);
|
return Ok((all_numbers_ids | all_strings_ids) - docids);
|
||||||
} /*
|
}
|
||||||
Condition::GeoLowerThan(base_point, distance) => {
|
|
||||||
let rtree = match index.geo_rtree(rtxn)? {
|
|
||||||
Some(rtree) => rtree,
|
|
||||||
None => return Ok(RoaringBitmap::new()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = rtree
|
|
||||||
.nearest_neighbor_iter(base_point)
|
|
||||||
.take_while(|point| {
|
|
||||||
distance_between_two_points(base_point, point.geom()) < *distance
|
|
||||||
})
|
|
||||||
.map(|point| point.data)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
Condition::GeoGreaterThan(point, distance) => {
|
|
||||||
let result = Self::evaluate_operator(
|
|
||||||
rtxn,
|
|
||||||
index,
|
|
||||||
numbers_db,
|
|
||||||
strings_db,
|
|
||||||
field_id,
|
|
||||||
&Condition::GeoLowerThan(point.clone(), *distance),
|
|
||||||
)?;
|
|
||||||
let geo_faceted_doc_ids = index.geo_faceted_documents_ids(rtxn)?;
|
|
||||||
return Ok(geo_faceted_doc_ids - result);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ask for the biggest value that can exist for this specific field, if it exists
|
// Ask for the biggest value that can exist for this specific field, if it exists
|
||||||
@ -337,8 +308,34 @@ impl<'a> Filter<'a> {
|
|||||||
Ok(lhs & rhs)
|
Ok(lhs & rhs)
|
||||||
}
|
}
|
||||||
FilterCondition::Empty => Ok(RoaringBitmap::new()),
|
FilterCondition::Empty => Ok(RoaringBitmap::new()),
|
||||||
// TODO: TAMO
|
FilterCondition::GeoLowerThan { point, radius } => {
|
||||||
_ => panic!("do the geosearch"),
|
let base_point = [parse(&point[0])?, parse(&point[1])?];
|
||||||
|
let radius = parse(&radius)?;
|
||||||
|
let rtree = match index.geo_rtree(rtxn)? {
|
||||||
|
Some(rtree) => rtree,
|
||||||
|
None => return Ok(RoaringBitmap::new()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = rtree
|
||||||
|
.nearest_neighbor_iter(&base_point)
|
||||||
|
.take_while(|point| {
|
||||||
|
distance_between_two_points(&base_point, point.geom()) < radius
|
||||||
|
})
|
||||||
|
.map(|point| point.data)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
FilterCondition::GeoGreaterThan { point, radius } => {
|
||||||
|
let result = Self::evaluate(
|
||||||
|
&FilterCondition::GeoLowerThan { point: point.clone(), radius: radius.clone() }
|
||||||
|
.into(),
|
||||||
|
rtxn,
|
||||||
|
index,
|
||||||
|
)?;
|
||||||
|
let geo_faceted_doc_ids = index.geo_faceted_documents_ids(rtxn)?;
|
||||||
|
return Ok(geo_faceted_doc_ids - result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user