You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugSomething isn't workingstaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedtriageIssue needs to be triaged/prioritized
The code in python3.10/site-packages/llama_index/vector_stores/mongodb/base.py
The below code only retains the last filter condition by replacing the existing key value pair.
def_to_mongodb_filter(standard_filters: MetadataFilters) ->Dict:
"""Convert from standard dataclass to filter dict."""filters= {}
forfilterinstandard_filters.legacy_filters():
filters[filter.key] =filter.valuereturnfilters
@sunilsamsonsuresh Hello there! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind.
To fix the _to_mongodb_filter function to handle multiple filter conditions without replacing the existing key-value pairs, you can modify the function to use the $and operator. This way, each filter condition is added as a separate dictionary within an array, ensuring that multiple conditions are combined correctly.
Here is the updated _to_mongodb_filter function:
def_to_mongodb_filter(standard_filters: MetadataFilters) ->Dict:
"""Convert from standard dataclass to filter dict."""filters= []
forfilterinstandard_filters.legacy_filters():
filters.append({filter.key: filter.value})
return {"$and": filters} iffilterselse {}
This modification ensures that multiple filter conditions are combined using the $and operator, allowing MongoDB to handle them correctly without overwriting existing key-value pairs [1][2].
bugSomething isn't workingstaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedtriageIssue needs to be triaged/prioritized
Bug Description
The code in
python3.10/site-packages/llama_index/vector_stores/mongodb/base.py
The below code only retains the last filter condition by replacing the existing key value pair.
Version
0.10.44
Steps to Reproduce
Apply multiple filters to reproduce this
Relevant Logs/Tracbacks
No response
The text was updated successfully, but these errors were encountered: