diff --git a/definitions/stage/vectorSearch.yaml b/definitions/stage/vectorSearch.yaml index f08789d7..aa1bce8a 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: @@ -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