fix logic

This commit is contained in:
nnethercott 2025-05-26 18:20:55 +02:00
parent 6738a4f6ee
commit 18aed75d3b
2 changed files with 31 additions and 31 deletions

View File

@ -2039,14 +2039,6 @@ async fn update_documents_with_geo_field() {
@r###" @r###"
{ {
"hits": [ "hits": [
{
"id": "4",
"_geo": {
"lat": "4",
"lng": "0"
},
"_geoDistance": 667170
},
{ {
"id": "3", "id": "3",
"_geo": { "_geo": {
@ -2056,6 +2048,14 @@ async fn update_documents_with_geo_field() {
"doggo": "kefir", "doggo": "kefir",
"_geoDistance": 555975 "_geoDistance": 555975
}, },
{
"id": "4",
"_geo": {
"lat": "4",
"lng": "0"
},
"_geoDistance": 667170
},
{ {
"id": "1" "id": "1"
}, },

View File

@ -170,10 +170,10 @@ impl FacetedDocidsExtractor {
let has_changed_for_geo_fields = let has_changed_for_geo_fields =
inner.has_changed_for_geo_fields(rtxn, index, context.db_fields_ids_map)?; inner.has_changed_for_geo_fields(rtxn, index, context.db_fields_ids_map)?;
if has_changed {
// 1. Delete old facet values // 1. Delete old facet values
let mut del = facet_fn!(del); let mut del = facet_fn!(del);
if has_changed {
extract_document_facets( extract_document_facets(
inner.current(rtxn, index, context.db_fields_ids_map)?, inner.current(rtxn, index, context.db_fields_ids_map)?,
new_fields_ids_map.deref_mut(), new_fields_ids_map.deref_mut(),
@ -183,7 +183,7 @@ impl FacetedDocidsExtractor {
distinct_field, distinct_field,
&mut del, &mut del,
)?; )?;
}
if is_geo_enabled && has_changed_for_geo_fields { if is_geo_enabled && has_changed_for_geo_fields {
extract_geo_document( extract_geo_document(
inner.current(rtxn, index, context.db_fields_ids_map)?, inner.current(rtxn, index, context.db_fields_ids_map)?,
@ -196,6 +196,7 @@ impl FacetedDocidsExtractor {
// 2. Insert new facet values // 2. Insert new facet values
let mut add = facet_fn!(add); let mut add = facet_fn!(add);
if has_changed {
extract_document_facets( extract_document_facets(
inner.merged(rtxn, index, context.db_fields_ids_map)?, inner.merged(rtxn, index, context.db_fields_ids_map)?,
new_fields_ids_map.deref_mut(), new_fields_ids_map.deref_mut(),
@ -205,7 +206,7 @@ impl FacetedDocidsExtractor {
distinct_field, distinct_field,
&mut add, &mut add,
)?; )?;
}
if is_geo_enabled && has_changed_for_geo_fields { if is_geo_enabled && has_changed_for_geo_fields {
extract_geo_document( extract_geo_document(
inner.merged(rtxn, index, context.db_fields_ids_map)?, inner.merged(rtxn, index, context.db_fields_ids_map)?,
@ -215,7 +216,6 @@ impl FacetedDocidsExtractor {
)?; )?;
} }
} }
}
DocumentChange::Insertion(inner) => { DocumentChange::Insertion(inner) => {
let mut add = facet_fn!(add); let mut add = facet_fn!(add);