pyes.connection

pyes.connection.connect(servers=None, framed_transport=False, timeout=None, retry_time=60, recycle=None, round_robin=None, max_retries=3)

Constructs a single ElasticSearch connection. Connects to a randomly chosen server on the list.

If the connection fails, it will attempt to connect to each server on the list in turn until one succeeds. If it is unable to find an active server, it will throw a NoServerAvailable exception.

Failing servers are kept on a separate list and eventually retried, no sooner than retry_time seconds after failure.

Parameters:
  • servers – [server] List of ES servers with format: “hostname:port” Default: [(“127.0.0.1”,9500)]
  • framed_transport – If True, use a TFramedTransport instead of a TBufferedTransport
  • timeout – Timeout in seconds (e.g. 0.5) Default: None (it will stall forever)
  • retry_time – Minimum time in seconds until a failed server is reinstated. (e.g. 0.5) Default: 60
  • recycle – Max time in seconds before an open connection is closed and returned to the pool. Default: None (Never recycle)
  • max_retries – Max retry time on connection down
  • round_robinDEPRECATED

:return ES client

pyes.connection.connect_thread_local(servers=None, framed_transport=False, timeout=None, retry_time=60, recycle=None, round_robin=None, max_retries=3)

Constructs a single ElasticSearch connection. Connects to a randomly chosen server on the list.

If the connection fails, it will attempt to connect to each server on the list in turn until one succeeds. If it is unable to find an active server, it will throw a NoServerAvailable exception.

Failing servers are kept on a separate list and eventually retried, no sooner than retry_time seconds after failure.

Parameters:
  • servers – [server] List of ES servers with format: “hostname:port” Default: [(“127.0.0.1”,9500)]
  • framed_transport – If True, use a TFramedTransport instead of a TBufferedTransport
  • timeout – Timeout in seconds (e.g. 0.5) Default: None (it will stall forever)
  • retry_time – Minimum time in seconds until a failed server is reinstated. (e.g. 0.5) Default: 60
  • recycle – Max time in seconds before an open connection is closed and returned to the pool. Default: None (Never recycle)
  • max_retries – Max retry time on connection down
  • round_robinDEPRECATED

:return ES client

exception pyes.connection.NoServerAvailable