Skip to content

Commit

Permalink
chore: Weaviate - remove legacy filter support (#1070)
Browse files Browse the repository at this point in the history
* Remove legacy filter support

* Linting

* Remove outdated test

* Improve error message

* Error msg fmt
  • Loading branch information
vblagoje authored Sep 12, 2024
1 parent 69946c0 commit 4f19d57
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from haystack.dataclasses.document import Document
from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError
from haystack.document_stores.types.policy import DuplicatePolicy
from haystack.utils.filters import convert

import weaviate
from weaviate.collections.classes.data import DataObject
Expand Down Expand Up @@ -388,7 +387,8 @@ def filter_documents(self, filters: Optional[Dict[str, Any]] = None) -> List[Doc
:returns: A list of Documents that match the given filters.
"""
if filters and "operator" not in filters and "conditions" not in filters:
filters = convert(filters)
msg = "Invalid filter syntax. See https://docs.haystack.deepset.ai/docs/metadata-filtering for details."
raise ValueError(msg)

result = []
if filters:
Expand Down
9 changes: 0 additions & 9 deletions integrations/weaviate/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,6 @@ def test_embedding_retrieval_with_distance_and_certainty(self, document_store):
with pytest.raises(ValueError):
document_store._embedding_retrieval(query_embedding=[], distance=0.1, certainty=0.1)

def test_filter_documents_with_legacy_filters(self, document_store):
docs = []
for index in range(10):
docs.append(Document(content="This is some content", meta={"index": index}))
document_store.write_documents(docs)
result = document_store.filter_documents({"content": {"$eq": "This is some content"}})

assert len(result) == 10

def test_filter_documents_below_default_limit(self, document_store):
docs = []
for index in range(9998):
Expand Down

0 comments on commit 4f19d57

Please sign in to comment.