feat: Add warnings to PineconeDocumentStore about indexing metadata if filters return no documents (#3086)

* black-jupyter format changes

* fix merge

* filters and documents/ids list evaluations fix (for this specific warning context)
This commit is contained in:
Fernando Pereira 2022-08-30 16:02:07 +01:00 committed by GitHub
parent f010a17f04
commit 911a2fa7e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -636,6 +636,13 @@ class PineconeDocumentStore(BaseDocumentStore):
namespace = self.document_namespace
ids = self._get_all_document_ids(index=index, namespace=namespace, filters=filters, batch_size=batch_size)
if filters is not None and len(ids) == 0:
logger.warning(
"This query might have been done without metadata indexed and thus no DOCUMENTS were retrieved. "
"Make sure the desired metadata you want to filter with is indexed."
)
for i in range(0, len(ids), batch_size):
i_end = min(len(ids), i + batch_size)
documents = self.get_documents_by_id(
@ -1127,6 +1134,12 @@ class PineconeDocumentStore(BaseDocumentStore):
vector_id_matrix, meta_matrix, values=values, index=index, return_embedding=return_embedding
)
if filters is not None and len(documents) == 0:
logger.warning(
"This query might have been done without metadata indexed and thus no results were retrieved. "
"Make sure the desired metadata you want to filter with is indexed."
)
# assign query score to each document
scores_for_vector_ids: Dict[str, float] = {str(v_id): s for v_id, s in zip(vector_id_matrix, score_matrix)}
for doc in documents: