haystack icon indicating copy to clipboard operation
haystack copied to clipboard

I am using Faiss Document store. When I call get_document_count function along with filters, it is returning zero

Open Srimathi10 opened this issue 1 year ago • 3 comments

Srimathi10 avatar Oct 10 '24 08:10 Srimathi10

Can you please provide a reproducible code example?

anakin87 avatar Oct 10 '24 20:10 anakin87

from haystack.document_stores import FAISSDocumentStore document_store = FAISSDocumentStore( sql_url="sqlite:///c:/py/faiss_document_store.db" )

Adding documents with content and metadata

documents = [ { "content": "This is the first document about machine learning.", "meta": { "title": "Document1", "author": "AuthorA", "date": "2024-01-01" } }, { "content": "This is the second document about deep learning.", "meta": { "title": "Document2", "author": "AuthorB", "date": "2024-01-02" } }, { "content": "This document discusses natural language processing.", "meta": { "title": "Document3", "author": "AuthorA", "date": "2024-01-03" } } ]

document_store.write_documents(documents)

filters={"author": {"$eq": "AuthorA"}}

print(document_store.get_document_count(filters=filters)) #It is returing 0 --Incorrect

print(len(document_store.get_all_documents(filters=filters))) #It is returing 2 --Correct

Srimathi10 avatar Oct 11 '24 07:10 Srimathi10

I can confirm the bug.

I don't know if we will work on fixing this as it seems relatively minor and affects 1.x (which is maintenance mode). We're concentrating our efforts on Haystack 2.x.

anakin87 avatar Oct 16 '24 08:10 anakin87

@Srimathi10 Have you considered switching to Haystack version 2.x and using one of the many other DocumentStores we have available in the most recent version of Haystack?

julian-risch avatar Oct 21 '24 07:10 julian-risch

Closing as won't fix in Haystack version 1.x. Please switch to version 2.x.

julian-risch avatar Feb 17 '25 07:02 julian-risch