Fix filter syntax validation (#8477)

This commit is contained in:
Amna Mubashar 2024-10-29 13:21:49 +01:00 committed by GitHub
parent c7b898994e
commit 811a54a3ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,9 +16,9 @@ def raise_on_invalid_filter_syntax(filters: Optional[Dict[str, Any]] = None):
"""
Raise an error if the filter syntax is invalid.
"""
if filters and "operator" not in filters and "conditions" not in filters:
if filters and ("operator" not in filters or "conditions" not in filters):
msg = "Invalid filter syntax. See https://docs.haystack.deepset.ai/docs/metadata-filtering for details."
raise ValueError(msg)
raise FilterError(msg)
def document_matches_filter(filters: Dict[str, Any], document: Document) -> bool: