fix: include exact in MongoDB search_param - #852
Conversation
search_embedding indexes search_params["exact"] on every query, but search_param() only returned num_candidates_ratio, so MongoDB search crashed with KeyError. Default remains False (ANN).
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: daviddallakyan2005 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Mock collection.aggregate so ANN vs exact pipelines and a missing exact key are covered; pymongo is stubbed when the extra is absent.
c786b59 to
9e693ae
Compare
| metric_type: MetricType = MetricType.COSINE | ||
| num_candidates_ratio: int = 10 # Default numCandidates ratio for vector search | ||
| quantization: QuantizationType = QuantizationType.NONE # Quantization type if applicable | ||
| exact: bool = False # Atlas $vectorSearch exact (ENN); default ANN |
There was a problem hiding this comment.
[P2] Expose exact search in the MongoDB performance UI
This adds exact as a public case option, but MongoDBPerformanceConfig still exposes only quantization and num_candidates_ratio. The frontend task builder instantiates MongoDBIndexConfig from those UI-selected fields, so every frontend-created MongoDB run keeps the False default and users cannot select the ENN workload described here.
Please add a Boolean exact input with default False to the MongoDB performance configuration and cover the task-generation path. If ENN is intentionally programmatic-only, please document that scope instead.
There was a problem hiding this comment.
I added a Boolean Exact (ENN) input, default False, to MongoDBPerformanceConfig. generate_tasks now forwards it onto MongoDBIndexConfig.exact.
MongoDBPerformanceConfig only offered quantization and num_candidates_ratio, so frontend runs could not select ENN.
Drop the _IndexConfig stub that hid the missing exact key. Filter search tests now construct MongoDBIndexConfig() after rebasing onto zilliztech#852.
Summary
MongoDB search crashes on every query with
KeyError: 'exact'.search_embeddingindexessearch_params["exact"], butMongoDBIndexConfig.search_param()only returnednum_candidates_ratio.This adds
exact: bool = Falseand emits it fromsearch_param(), and reads the key with.get("exact"). The default stays ANN (numCandidates).exact=Trueenables Atlas$vectorSearchENN.The MongoDB performance UI now has a Boolean Exact (ENN) input, default False, so frontend task generation can select ENN.
How to test
CI
make unittestis a single network download and will not run this file.pip install -e '.[test]' make lint PYTHONPATH=. python3 -m pytest tests/test_mongodb_config.py tests/test_db_client_resolution.py -q