Deepset Haystack Secure Connection to Elasticsearch

283 Views Asked by At

I am trying to create a Haystack document store with Elasticsearch (run on Docker with security) but I am getting the following errors. I know I need to tell Haystack to use https but I couldn't find a how in the docs. I did try specifying port 9300 and 9200.

document_store = ElasticsearchDocumentStore(
    host='https://localhost', 
    username= 'elastic',
    password='{PASSWORD}',
    port=9200,
    index='squad_docs'
)

Haystack errors in the Python console

ConnectionError: ConnectionError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))) caused by: ProtocolError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

Elasticsearch WARN in the logs

{"@timestamp":"2022-11-08T14:01:54.875Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.18.0.2:9200, remoteAddress=/172.18.0.1:56568}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[c759978b5b07][transport_worker][T#1]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"vDXCcs4uQM-gcuf5vciZkA","elasticsearch.node.id":"VunPyrAPRbG9PrLFyZ1E8w","elasticsearch.node.name":"c759978b5b07","elasticsearch.cluster.name":"docker-cluster"}
1

There are 1 best solutions below

1
On

The ElasticsearchDocumentStore has a parameter scheme which you need to set to "https". You might want to have a look at the documentation to see all available parameters.