From 31b0ea9e0f4b18e642bbb818301e7303aff299d9 Mon Sep 17 00:00:00 2001 From: Casey Clements Date: Mon, 30 Sep 2024 17:10:52 -0400 Subject: [PATCH 1/2] Increased default retries --- tests/index/mongo_atlas/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/index/mongo_atlas/__init__.py b/tests/index/mongo_atlas/__init__.py index 360ba6ee1c..305bebe1ed 100644 --- a/tests/index/mongo_atlas/__init__.py +++ b/tests/index/mongo_atlas/__init__.py @@ -29,7 +29,7 @@ class FlatSchema(BaseDoc): embedding2: NdArray = Field(dim=N_DIM, index_name="vector_index_2") -def assert_when_ready(callable: Callable, tries: int = 5, interval: float = 2): +def assert_when_ready(callable: Callable, tries: int = 10, interval: float = 2): """ Retry callable to account for time taken to change data on the cluster """ From 468841d9d35117565737f41375ab9537670314a2 Mon Sep 17 00:00:00 2001 From: Casey Clements Date: Mon, 30 Sep 2024 17:12:17 -0400 Subject: [PATCH 2/2] Improved handling of filters --- docarray/index/backends/mongodb_atlas.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docarray/index/backends/mongodb_atlas.py b/docarray/index/backends/mongodb_atlas.py index f2bbc04983..f1ccdec02d 100644 --- a/docarray/index/backends/mongodb_atlas.py +++ b/docarray/index/backends/mongodb_atlas.py @@ -563,16 +563,18 @@ def _vector_search_stage( max_candidates = self._get_max_candidates(search_field) query = query.astype(np.float64).tolist() - return { + stage = { '$vectorSearch': { 'index': search_index_name, 'path': search_field, 'queryVector': query, 'numCandidates': min(limit * oversampling_factor, max_candidates), 'limit': limit, - 'filter': {"$and": filters} if filters else None, } } + if filters: + stage['$vectorSearch']['filter'] = {"$and": filters} + return stage def _text_search_stage( self,