Skip to content

fix: include exact in MongoDB search_param - #852

Open
daviddallakyan2005 wants to merge 3 commits into
zilliztech:mainfrom
daviddallakyan2005:mongodb-exact-keyerror
Open

fix: include exact in MongoDB search_param#852
daviddallakyan2005 wants to merge 3 commits into
zilliztech:mainfrom
daviddallakyan2005:mongodb-exact-keyerror

Conversation

@daviddallakyan2005

@daviddallakyan2005 daviddallakyan2005 commented Aug 15, 2026

Copy link
Copy Markdown

Summary

MongoDB search crashes on every query with KeyError: 'exact'. search_embedding indexes search_params["exact"], but MongoDBIndexConfig.search_param() only returned num_candidates_ratio.

This adds exact: bool = False and emits it from search_param(), and reads the key with .get("exact"). The default stays ANN (numCandidates). exact=True enables Atlas $vectorSearch ENN.

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 unittest is 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

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).
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: daviddallakyan2005
To complete the pull request process, please assign xuanyang-cn after the PR has been reviewed.
You can assign the PR to them by writing /assign @xuanyang-cn in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Mock collection.aggregate so ANN vs exact pipelines and a missing
exact key are covered; pymongo is stubbed when the extra is absent.

@jamesgao-jpg jamesgao-jpg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the contribution! Please take a look at below reviews when you get a chance. Thanks!

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
daviddallakyan2005 added a commit to daviddallakyan2005/VectorDBBench that referenced this pull request Aug 27, 2026
Drop the _IndexConfig stub that hid the missing exact key. Filter
search tests now construct MongoDBIndexConfig() after rebasing onto zilliztech#852.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants