Search code examples
pythonelasticsearchnlpdocument-storehaystack

ModuleNotFoundError: No module named 'haystack.document_store.elasticsearch'; 'haystack.document_store' is not a package


I am building a Q&A webapp with elasticsearch. I have just successfully installed farm-haystack==1.3.0 and farm with requirements.txt.

Now when I import the library, it pops up an error:

from haystack.document_store.elasticsearch import ElasticsearchDocumentStore
# from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore


document_store = ElasticsearchDocumentStore(host="localhost", username="", password="", index="document")

error:

ModuleNotFoundError: No module named 'haystack.document_store.elasticsearch'; 'haystack.document_store' is not a package

It would be great if anyone can tell me how to fix it. I have made sure my haystack.document_store.elasticsearch is not document_store's'.


Solution

  • According to the haystack documentation https://haystack.deepset.ai/overview/migration, since version 1.0, ElasticsearchDocumentStore can be directly accessed from haystack.document_stores.

    from haystack.document_stores import ElasticsearchDocumentStore
    

    Also note that the plural of document_store's' is necessary for versions after 1.0 as well. That is the "s" is needed at the end of "document_stores".