1

I'm trying to close a connection to my elasticsearch cluster in my application code using elasticsearch-py.

Currently, I'm using:

es = Elasticsearch()
es.close()

But, I'm getting the error:

Traceback (most recent call last):
  File "tmp.py", line 45, in <module>
    es.close()
AttributeError: 'Elasticsearch' object has no attribute 'close'

I haven't seen any close methods in the documentation either:

https://elasticsearch-py.readthedocs.io/en/master/api.html

Any help would be greatly appreciated! Thanks in advance :)

Ronak Vora
  • 185
  • 3
  • 16

1 Answers1

8

You can close the transport with Transport.close:

es = Elasticsearch()
es.transport.close()
Blender
  • 289,723
  • 53
  • 439
  • 496