Skip to content

fix: wire MongoDB label filters through prepare_filter - #853

Open
daviddallakyan2005 wants to merge 2 commits into
zilliztech:mainfrom
daviddallakyan2005:mongodb-filtered-search
Open

fix: wire MongoDB label filters through prepare_filter#853
daviddallakyan2005 wants to merge 2 commits into
zilliztech:mainfrom
daviddallakyan2005:mongodb-filtered-search

Conversation

@daviddallakyan2005

@daviddallakyan2005 daviddallakyan2005 commented Aug 15, 2026

Copy link
Copy Markdown

Summary

MongoDB label-filter cases were silently unfiltered (recall ~0.111 vs ~0.982 once labels actually reach $vectorSearch). The runner already passes labels_data= into insert and calls prepare_filter then search_embedding(query, k) — it never passes filters= into search. This wires the four missing pieces, matching qdrant_cloud:

  • declare supported_filter_types = [NonFilter, StrEqual] so label cases are not skipped
  • persist labels_data on documents as label when with_scalar_labels
  • prepare_filter stashes {label: <value>} for search to apply
  • add {type: "filter", path: "label"} to the vector search index when with_scalar_labels (Atlas rejects undeclared filter paths)

Does not add ingest-once metadata_fields, dict labels_data, or NumGE.

How to test

PYTHONPATH=. python3 -m pytest tests/test_mongodb_client.py -q
make lint

make unittest is the network dataset download only and does not run this file.

Filtered search silently ignored labels because insert dropped
labels_data, prepare_filter was a no-op, and the vector index never
declared path label. Mirror qdrant_cloud for StrEqual only.
@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

Expand offline mocks for filter_supported, runner insert kwargs,
leftover filters= on search, and optimize index declaration.
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