From 39366a67c40c000ecd436a68580a7d3523db6390 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 7 Nov 2024 10:39:58 +0100 Subject: [PATCH] Top level fields don't return vector fields --- crates/milli/src/update/new/document.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/milli/src/update/new/document.rs b/crates/milli/src/update/new/document.rs index 14e4f72e5..f43eb63e4 100644 --- a/crates/milli/src/update/new/document.rs +++ b/crates/milli/src/update/new/document.rs @@ -27,6 +27,9 @@ pub trait Document<'doc> { self.len() == 0 } + /// Get the **top-level** with the specified name, if exists. + /// + /// - The `_vectors` and `_geo` fields are **ignored** by this method, meaning e.g. `top_level_field("_vectors")` will return `Ok(None)` fn top_level_field(&self, k: &str) -> Result>; /// Returns the unparsed value of the `_vectors` field from the document data. @@ -105,6 +108,9 @@ impl<'t, Mapper: FieldIdMapper> Document<'t> for DocumentFromDb<'t, Mapper> { } fn top_level_field(&self, k: &str) -> Result> { + if k == RESERVED_VECTORS_FIELD_NAME || k == "_geo" { + return Ok(None); + } self.field(k) } } @@ -393,6 +399,9 @@ impl<'doc> Versions<'doc> { self.data.is_empty() } pub fn top_level_field(&self, k: &str) -> Option<&'doc RawValue> { + if k == RESERVED_VECTORS_FIELD_NAME || k == "_geo" { + return None; + } self.data.get(k) } }