From 59a5b314bebb8b19a71facf0be52a6b1efd43e59 Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Thu, 12 Sep 2024 14:59:35 +0200 Subject: [PATCH] chore: Pinecone - remove legacy filter support (#1069) * Remove legacy filter support * Linting * Improve error message * Improve error message - lint * Change message to be more generic * Error msg fmt --- .../document_stores/pinecone/document_store.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integrations/pinecone/src/haystack_integrations/document_stores/pinecone/document_store.py b/integrations/pinecone/src/haystack_integrations/document_stores/pinecone/document_store.py index 75d6270ca..07f217f5b 100644 --- a/integrations/pinecone/src/haystack_integrations/document_stores/pinecone/document_store.py +++ b/integrations/pinecone/src/haystack_integrations/document_stores/pinecone/document_store.py @@ -11,7 +11,6 @@ from haystack.dataclasses import Document from haystack.document_stores.types import DuplicatePolicy from haystack.utils import Secret, deserialize_secrets_inplace -from haystack.utils.filters import convert from pinecone import Pinecone, PodSpec, ServerlessSpec @@ -201,6 +200,10 @@ 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: + msg = "Invalid filter syntax. See https://docs.haystack.deepset.ai/docs/metadata-filtering for details." + raise ValueError(msg) + # Pinecone only performs vector similarity search # here we are querying with a dummy vector and the max compatible top_k documents = self._embedding_retrieval(query_embedding=self._dummy_vector, filters=filters, top_k=TOP_K_LIMIT) @@ -253,7 +256,8 @@ def _embedding_retrieval( raise ValueError(msg) if filters and "operator" not in filters and "conditions" not in filters: - filters = convert(filters) + msg = "Legacy filters support has been removed. Please see documentation for new filter syntax." + raise ValueError(msg) filters = _normalize_filters(filters) if filters else None result = self.index.query(