mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Optimize geo sort
This commit is contained in:
parent
8326f34ad1
commit
8aacd6374a
1 changed files with 9 additions and 1 deletions
|
@ -370,7 +370,7 @@ pub fn recursive_facet_sort<'ctx>(
|
|||
|
||||
let mut fields = Vec::new();
|
||||
let fields_ids_map = index.fields_ids_map(rtxn)?;
|
||||
let geo_candidates = index.geo_faceted_documents_ids(rtxn)?; // TODO: skip when no geo sort
|
||||
let mut need_geo_candidates = false;
|
||||
for sort in sort {
|
||||
match sort {
|
||||
AscDesc::Asc(Member::Field(field)) => {
|
||||
|
@ -387,6 +387,7 @@ pub fn recursive_facet_sort<'ctx>(
|
|||
if let (Some(lat), Some(lng)) =
|
||||
(fields_ids_map.id("_geo.lat"), fields_ids_map.id("_geo.lng"))
|
||||
{
|
||||
need_geo_candidates = true;
|
||||
fields.push(AscDescId::Geo {
|
||||
field_ids: [lat, lng],
|
||||
target_point,
|
||||
|
@ -398,6 +399,7 @@ pub fn recursive_facet_sort<'ctx>(
|
|||
if let (Some(lat), Some(lng)) =
|
||||
(fields_ids_map.id("_geo.lat"), fields_ids_map.id("_geo.lng"))
|
||||
{
|
||||
need_geo_candidates = true;
|
||||
fields.push(AscDescId::Geo {
|
||||
field_ids: [lat, lng],
|
||||
target_point,
|
||||
|
@ -409,6 +411,12 @@ pub fn recursive_facet_sort<'ctx>(
|
|||
// FIXME: Should this return an error if the field is not found?
|
||||
}
|
||||
|
||||
let geo_candidates = if need_geo_candidates {
|
||||
index.geo_faceted_documents_ids(rtxn)?
|
||||
} else {
|
||||
RoaringBitmap::new()
|
||||
};
|
||||
|
||||
let number_db = index.facet_id_f64_docids.remap_key_type::<FacetGroupKeyCodec<BytesRefCodec>>();
|
||||
let string_db =
|
||||
index.facet_id_string_docids.remap_key_type::<FacetGroupKeyCodec<BytesRefCodec>>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue