haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Unable to update data

Open monika1800 opened this issue 5 years ago • 5 comments

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.

monika1800 avatar Jun 01 '21 09:06 monika1800

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 avatar Jun 01 '21 09:06 julian-risch

@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.

monika1800 avatar Jun 01 '21 09:06 monika1800

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.

julian-risch avatar Jun 01 '21 10:06 julian-risch

Hi @monika1800 did you manage to resolve your problem?

julian-risch avatar Jun 08 '21 13:06 julian-risch

Hi @julian-risch, Thank you. I am able to run now the update method with previous version of haystack.

monika1800 avatar Jun 09 '21 10:06 monika1800