From 7241e4b4f897ebd94493bec29831f89cade7c092 Mon Sep 17 00:00:00 2001 From: Pauline Vos Date: Thu, 7 May 2026 16:39:44 +0200 Subject: [PATCH 1/2] Remove mention of "no decimals" from filter description It's not mentioned anywhere in the docs (or ever has been), and I'm unsure where it camefrom. Removing it for clarity. --- definitions/stage/vectorSearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/stage/vectorSearch.yaml b/definitions/stage/vectorSearch.yaml index f08789d7..300f7672 100644 --- a/definitions/stage/vectorSearch.yaml +++ b/definitions/stage/vectorSearch.yaml @@ -41,7 +41,7 @@ arguments: type: - query description: | - Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + Any match query that compares an indexed field with a boolean, date, objectId, number, string, or UUID to use as a pre-filter. - name: numCandidates optional: true type: From e346b3a61d5a4aabe0537d46e49aa8969aa67056 Mon Sep 17 00:00:00 2001 From: Pauline Vos Date: Thu, 7 May 2026 16:39:44 +0200 Subject: [PATCH 2/2] Support nested fields in vector search --- definitions/stage/vectorSearch.yaml | 57 +++++++++++++++++++++++++++++ scripts/lint.sh | 0 2 files changed, 57 insertions(+) mode change 100644 => 100755 scripts/lint.sh diff --git a/definitions/stage/vectorSearch.yaml b/definitions/stage/vectorSearch.yaml index 300f7672..aa1bce8a 100644 --- a/definitions/stage/vectorSearch.yaml +++ b/definitions/stage/vectorSearch.yaml @@ -55,6 +55,25 @@ arguments: - bool description: | If true, the search returns only the stored source fields configured on the index directly from the index and skips a full document lookup. If omitted, the default value is false. + - name: nestedOptions + optional: true + type: + - object + description: | + Configure how MongoDB Vector Search scores documents that contain nested arrays. + arguments: + - name: scoreMode + optional: true + type: + - string + description: | + Specifies how to score documents that contain nested arrays. Value can be avg or max. + - name: parentFilter + optional: true + type: + - query + description: | + Any match query that compares an indexed top-level field with a boolean, date, objectId, number, string, or UUID to use as a pre-filter. Only valid if `nestedRoot` is specified in the index definition. tests: - name: ANN Basic link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#examples @@ -209,3 +228,41 @@ tests: title: types: - bsonType: String + - name: Nested field + link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#examples + pipeline: + - $vectorSearch: + index: vector_index + filter: + reviews.date: + $gte: !bson_utcdatetime "2000-01-01" + parentFilter: + address.country: + $in: + - United States + bedrooms: + $gte: 2 + $lte: 3 + property_type: + $in: + - House + - Apartment + path: reviews.comments_embedding + queryVector: # skip other numbers, not relevant to the test + - 0.010745884850621223 + - -0.035673413425683975 + - -0.09298479557037354 + numCandidates: 100 + limit: 5 + nestedOptions: + scoreMode: avg + - $project: + _id: 0 + name: 1 + address: 1 + neighborhood_overview: 1 + bedrooms: 1 + property_type: 1 + reviews.comments: 1 + score: + $meta: vectorSearchScore diff --git a/scripts/lint.sh b/scripts/lint.sh old mode 100644 new mode 100755