Repository navigation
Conversation
_create_where_document_filter only looked at the first condition of a logical operator. An AND with a metadata condition first was sent to Chroma's where clause as a whole, so the content condition became a metadata key and the filter silently matched nothing; with the content condition first, the same filter raised ChromaDocumentStoreFilterError. Chroma applies where and where_document together, so send the content and metadata conditions of a top-level AND to the two clauses.
Contributor
Coverage report (chroma)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
_create_where_document_filterdecides whether a logical filter is a content filter by looking only at its first condition (value[0]). For anANDthat mixes a content condition and a metadata condition, the result depends on the order:$andgoes to Chroma'swhere, socontentis treated as a metadata key and the filter silently matches nothing;ChromaDocumentStoreFilterError: Invalid 'document content filter' : Expected where document to have exactly one operator.In Haystack's filter syntax the order of
ANDconditions does not matter. Chroma applieswhereandwhere_documenttogether, so_convert_filtersnow sends the content conditions of a top-levelANDtowhere_documentand the other conditions towhere, in either order. If the non-content part itself contains a content condition (for example nested underOR), the previous code path is used unchanged.How did you test it?
tests/test_filters.py: the mixedANDin both orders, and one content condition with two metadata conditions. All three fail before the change and pass after it.pytest tests -m "not integration"inintegrations/chroma: 56 passed (53 passed and 3 failed before).ChromaDocumentStoreand three documents,filter_documentswithcontent contains "x" AND meta.a == 1returned[](metadata first) or raised (content first) before the change, and returns the matching document in both orders after it. I did not run the integration-marked tests.ruff checkandruff format --checkpass on the changed files.Notes for the reviewer
Open PRs #4124 (metadata
idfilters) and #3797 (empty filter conditions) touch the same module but different cases. AnORthat mixes content and metadata conditions cannot be expressed with Chroma's two separate clauses and is not changed here.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.