Skip to content

fix: include exact in MongoDB search_param - #852

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

fix: include exact in MongoDB search_param#852
daviddallakyan2005 wants to merge 2 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.

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

2 participants