fix: wire MongoDB label filters through prepare_filter - #853
fix: wire MongoDB label filters through prepare_filter#853daviddallakyan2005 wants to merge 5 commits into
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).
Mock collection.aggregate so ANN vs exact pipelines and a missing exact key are covered; pymongo is stubbed when the extra is absent.
|
[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 |
e1eb07e to
0a1772e
Compare
| } | ||
|
|
||
|
|
||
| class _IndexConfig(MongoDBIndexConfig): |
There was a problem hiding this comment.
[P2] Test the production config instead of hiding the PR #852 dependency
_IndexConfig adds exact=False, but the production MongoDBIndexConfig.search_param() on this head does not return exact, while search_embedding() reads search_params["exact"]. A focused reproduction using MongoDBIndexConfig() raises KeyError: 'exact' before $vectorSearch is built. Thus this PR only works if PR #852 lands first, but these tests mask that dependency. Please rebase onto #852 (and link it in the PR description), or include its fix here, then remove this subclass so the regression tests exercise the production config.
There was a problem hiding this comment.
I rebased this onto #852 and dropped _IndexConfig. The filter tests now construct MongoDBIndexConfig().
|
/assign @jamesgao-jpg |
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.
Expand offline mocks for filter_supported, runner insert kwargs, leftover filters= on search, and optimize index declaration.
Drop the _IndexConfig stub that hid the missing exact key. Filter search tests now construct MongoDBIndexConfig() after rebasing onto zilliztech#852.
0a1772e to
c3da748
Compare
|
Hi, 852 is merged and seems that a conflict needs to be resolved before 853 can get merged |
Summary
MongoDB label-filter cases were silently unfiltered (recall ~0.111 vs ~0.982 once labels actually reach
$vectorSearch). The runner already passeslabels_data=into insert and callsprepare_filterthensearch_embedding(query, k). It never passesfilters=into search. This wires the four missing pieces, matchingqdrant_cloud:supported_filter_types = [NonFilter, StrEqual]so label cases are not skippedlabels_dataon documents aslabelwhenwith_scalar_labelsprepare_filterstashes{label: <value>}for search to apply{type: "filter", path: "label"}to the vector search index whenwith_scalar_labels(Atlas rejects undeclared filter paths)Does not add ingest-once
metadata_fields, dictlabels_data, orNumGE.Rebased onto #852 so production
MongoDBIndexConfig.search_param()includesexact. Filter tests constructMongoDBIndexConfig()rather than a stub subclass.How to test
make unittestis the network dataset download only and does not run these files.21 passed.
make lintclean.tests/test_db_client_resolution.py43 passed.