Transport classes

List of transport classes that can be used, simply import your choice and pass it to the constructor of Elasticsearch as connection_class. Note that Thrift and Memcached protocols are experimental and require a plugin to be installed in your cluster as well as additional dependencies (thrift==0.9 and pylibmc==1.2).

For example to use the thrift connection just import it and use it. The connection classes are aware of their respective default ports (9500 for thrift) so there is no need to specify them unless modified:

from elasticsearch import Elasticsearch, ThriftConnection
es = Elasticsearch(connection_class=ThriftConnection)

Connection

class elasticsearch.connection.Connection(host='localhost', port=9200, url_prefix='', timeout=10, **kwargs)

Class responsible for maintaining a connection to an Elasticsearch node. It holds persistent connection pool to it and it’s main interface (perform_request) is thread-safe.

Also responsible for logging.

Parameters:
  • host – hostname of the node (default: localhost)
  • port – port to use (default: 9200)
  • url_prefix – optional url prefix for elasticsearch
  • timeout – default timeout in seconds (default: 10)

Urllib3HttpConnection

class elasticsearch.connection.Urllib3HttpConnection(host='localhost', port=9200, http_auth=None, use_ssl=False, maxsize=10, **kwargs)

Default connection class using the urllib3 library and the http protocol.

Parameters:
  • http_auth – optional http auth information as either ‘:’ separated string or a tuple
  • use_ssl – use ssl for the connection if True
  • maxsize – the maximum number of connections which will be kept open to this host.

RequestsHttpConnection

class elasticsearch.connection.RequestsHttpConnection(host='localhost', port=9200, http_auth=None, use_ssl=False, **kwargs)

Connection using the requests library.

Parameters:
  • http_auth – optional http auth information as either ‘:’ separated string or a tuple
  • use_ssl – use ssl for the connection if True

ThriftConnection

class elasticsearch.connection.ThriftConnection(host='localhost', port=9500, framed_transport=False, use_ssl=False, **kwargs)

Connection using the thrift protocol to communicate with elasticsearch.

See https://github.com/elasticsearch/elasticsearch-transport-thrift for additional info.

Parameters:framed_transport – use TTransport.TFramedTransport instead of

TTransport.TBufferedTransport

MemcachedConnection

class elasticsearch.connection.MemcachedConnection(host='localhost', port=11211, **kwargs)

Client using the pylibmc python library to communicate with elasticsearch using the memcached protocol. Requires plugin in the cluster.

See https://github.com/elasticsearch/elasticsearch-transport-memcached for more details.