I am using Haystack for searching query when i write documents in document store, Unfortunately This error occurred for me. Here is my code:
if __name__ == "__main__":
document_store = ElasticsearchDocumentStore(
host='localhost',
username='', password='',
index='aurelius'
)
df = pd.read_csv('news.csv')
print(df.columns)
data_json = [{
'text': text,
'meta': {
'source': 'news'
}
} for text in df['Text'].values]
document_store.write_documents(data_json)
retriever_elastic = DensePassageRetriever(
document_store=document_store,
query_embedding_model='facebook/dpr-question_encoder-single-nq-base',
passage_embedding_model='facebook/dpr-ctx_encoder-single-nq-base',
embed_title=True
)
document_store.update_embeddings(retriever=retriever_elastic)
print(retriever_elastic.retrieve("german business confidence slides german business confidence fell in february knocking hopes of a speedy recovery in europe s largest economy. "))
Based on @UninformedUser reply.
I assume that it is the document.store.write_documents(data_json)
that throws the exception. As the format for the argument has been changed from { 'text': str, 'meta': obj}
to {'content': str, 'meta': obj}
.
So basically you only need to fix the list comprehension part of your code:
data_json = [{
'content': text,
'meta': {
'source': 'news'
}
} for text in df['Text'].values]
document_store.write_documents(data_json)