Unable to update data
Question When I am trying to run the same document through the pipeline with update_existing_documents: True. I am seeing two versions of the same document with different ids created through ElasticSearchDocstore.
Additional context Wanted to understand what is the best approach to update the existing documents, add new documents in the existing pipeline.
Hi @monika1800 The document that is already stored in the document store will only be updated if the new document has the same id. Otherwise it will be added as a new document with a different id and thus you see multiple documents with the same text but different id. I recommend to have a look at this test: https://github.com/deepset-ai/haystack/blob/b76ed4c5a4cac54b92e6cad2dc8ce9da07935bc6/test/test_document_store.py#L163
The test shows what's the expected behavior. You could solve your problem by explicitly passing ids when you add documents to the document store. Does that answer your question?
@julian-risch I am trying to run document_store.write_documents(updated_docs, duplicate_documents="overwrite") with duplicate_documents="overwrite". Getting an error TypeError: write_documents() got an unexpected keyword argument 'duplicate_documents'. Is it part of current elasticsearch.py.
Sorry for the confusion, 7 days ago there were some changes to the handling of duplicate comments and I guess you don't have the latest version of the code at the moment. You could either check out the latest version from GitHub:
git clone https://github.com/deepset-ai/haystack.git
cd haystack
pip install --editable .
or you could have a look at the earlier version of the test case (it's a different link now): https://github.com/deepset-ai/haystack/blob/0633dae4d003b92343161da09522a76c1a218868/test/test_document_store.py#L141
I would recommend to check out the latest version from GitHub.
Hi @monika1800 did you manage to resolve your problem?
Hi @julian-risch, Thank you. I am able to run now the update method with previous version of haystack.