-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement filtering for WeaviateDocumentStore
#278
Conversation
d45b860
to
a5c157d
Compare
@@ -28,6 +26,7 @@ dependencies = [ | |||
"haystack-ai", | |||
"weaviate-client==3.*", | |||
"haystack-pydoc-tools", | |||
"python-dateutil", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this to have proper parsing of ISO 8601 dates as datetime.fromisoformat()
supports it properly only from 3.11
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great but challenging job!
I left two minor comments.
if value is None: | ||
# When the value is None and '>' is used we create a filter that would return a Document | ||
# if it has a field set and not set at the same time. | ||
# This will cause the filter to match no Document. | ||
# This way we keep the behavior consistent with other Document Stores. | ||
return { | ||
"operator": "And", | ||
"operands": [ | ||
{"path": field, "operator": "IsNull", "valueBoolean": False}, | ||
{"path": field, "operator": "IsNull", "valueBoolean": True}, | ||
], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood correctly, this is a trick to create a filter that returns no Documents.
It is done to keep the global filtering logic unaffected. Right?
If so, can we centralize that logic in a utility function?
if "field" not in condition: | ||
# 'field' key is only found in comparison dictionaries. | ||
# We assume this is a logic dictionary since it's not present. | ||
return _parse_logical_condition(condition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some time ago, in another PR, Massi made me notice that this might be better handled in the caller. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR add support for
filters
inWeaviateDocumentStore.filter_documents()
method.All tests are passing except for
test_comparison_not_equal_with_dataframe
.For some reason that test is not returning what we expect from Weaviate.
I decided to skip it for the time being as I wanted to get this out of the door.