Elasticsearch With Haystack -Initial connection to Elasticsearch failed

Hi

I am trying to run Chapter 7 to learn about Haystack for QA:

I am using Jupyter Notebook which is connected to my GCP VM : Debian GNU/Linux 9, Tesla V100
I did install debian version
but facing the following error : ConnectionError: Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at [{'host': 'localhost', 'port': 9200}] and that it has finished the initial ramp up (can take > 30s).

!wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz
!wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz.sha512
!shasum -a 512 -c elasticsearch-8.1.2-linux-x86_64.tar.gz.sha512
!tar -xzf elasticsearch-8.1.2-linux-x86_64.tar.gz
!cd elasticsearch-8.1.2/
!pip install pymilvus
import pymilvus
import os
from subprocess import Popen, PIPE, STDOUT

!chown -R daemon:daemon elasticsearch-8.1.2
es_server = Popen(args=[ā€˜elasticsearch-8.1.2/bin/elasticsearchā€™])
!sleep 30

from haystack.document_store.elasticsearch import ElasticsearchDocumentStore

#document_store = ElasticsearchDocumentStore(host=ā€˜localhostā€™, port= 9201, username=ā€™ā€™, password=ā€™ā€™)
document_store = ElasticsearchDocumentStore(return_embedding=True)

I would appreciate your support on this.

Shabnam

same problem here! I wonder if you have found a solution already?

Hi! the solution is launch ES:

from haystack.utils import launch_es
launch_es()

Before launching ES, we need to install docker to run ES locally, here the link to install docker
After Docker installed, we need to change permission to use it as $USER:

sudo usermod -aG docker $USER
sudo reboot

Thats all:)

1 Like

Hi,

After launch_es(), I saw the following error messages.
Can you help me for this problems.

Of course, I changed username using ā€˜usermodā€™

TypeError: create() got an unexpected keyword argument ā€˜mappingsā€™

#curl -X GET ā€œlocalhost:9200/?prettyā€

{
ā€œnameā€ : ā€œac91bb8c9894ā€,
ā€œcluster_nameā€ : ā€œdocker-clusterā€,
ā€œcluster_uuidā€ : ā€œZb5y5OaSQtGIuBVB-I3POQā€,
ā€œversionā€ : {
ā€œnumberā€ : ā€œ7.17.6ā€,
ā€œbuild_flavorā€ : ā€œdefaultā€,
ā€œbuild_typeā€ : ā€œdockerā€,
ā€œbuild_hashā€ : ā€œf65e9d338dc1d07b642e14a27f338990148ee5b6ā€,
ā€œbuild_dateā€ : ā€œ2022-08-23T11:08:48.893373482Zā€,
ā€œbuild_snapshotā€ : false,
ā€œlucene_versionā€ : ā€œ8.11.1ā€,
ā€œminimum_wire_compatibility_versionā€ : ā€œ6.8.0ā€,
ā€œminimum_index_compatibility_versionā€ : ā€œ6.0.0-beta1ā€
},
ā€œtaglineā€ : ā€œYou Know, for Searchā€
}

Thanks a lot in advance.