diff --git a/milli/src/search/facet/filter_condition.rs b/milli/src/search/facet/filter_condition.rs index 1480fc95a..66a2ffac7 100644 --- a/milli/src/search/facet/filter_condition.rs +++ b/milli/src/search/facet/filter_condition.rs @@ -463,6 +463,9 @@ impl FilterCondition { LowerThanOrEqual(val) => (Included(f64::MIN), Included(*val)), Between(left, right) => (Included(*left), Included(*right)), GeoLowerThan(point, distance) => { + if index.filterable_fields(rtxn)?.contains("_geo") { + Err(UserError::AttributeLimitReached)?; // TODO: TAMO use a real error + } let mut result = RoaringBitmap::new(); let rtree = match index.geo_rtree(rtxn)? { Some(rtree) => rtree, @@ -477,6 +480,9 @@ impl FilterCondition { return Ok(result); } GeoGreaterThan(point, distance) => { + if index.filterable_fields(rtxn)?.contains("_geo") { + Err(UserError::AttributeLimitReached)?; // TODO: TAMO use a real error + } let result = Self::evaluate_operator( rtxn, index, diff --git a/milli/src/update/delete_documents.rs b/milli/src/update/delete_documents.rs index cfd777d11..639770bd6 100644 --- a/milli/src/update/delete_documents.rs +++ b/milli/src/update/delete_documents.rs @@ -687,6 +687,8 @@ mod tests { let mut wtxn = index.write_txn().unwrap(); let mut builder = Settings::new(&mut wtxn, &index, 0); builder.set_primary_key(S("id")); + builder.set_filterable_fields(hashset!(S("_geo"))); + builder.set_sortable_fields(hashset!(S("_geo"))); builder.execute(|_, _| ()).unwrap(); let content = &r#"[ diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index ba550afb9..d4fd3570e 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -234,7 +234,13 @@ impl<'t, 'u, 'i, 'a> IndexDocuments<'t, 'u, 'i, 'a> { // get filterable fields for facet databases let faceted_fields = self.index.faceted_fields_ids(self.wtxn)?; // get the fid of the `_geo` field. - let geo_field_id = self.index.fields_ids_map(self.wtxn)?.id("_geo"); + let geo_field_id = if let Some(gfid) = self.index.fields_ids_map(self.wtxn)?.id("_geo") { + (self.index.sortable_fields_ids(self.wtxn)?.contains(&gfid) + || self.index.filterable_fields_ids(self.wtxn)?.contains(&gfid)) + .then(|| gfid) + } else { + None + }; let stop_words = self.index.stop_words(self.wtxn)?; // let stop_words = stop_words.as_ref();