Getting an ES

ElasticUtils uses pyes which comes with a handy ES object. This lets you work with ElasticSearch outside of what ElasticUtils can do.

To access this, you use get_es() which builds an ES.

elasticutils.get_es(hosts=None, default_indexes=None, timeout=None, dump_curl=None, **settings)

Create an ES object and return it.

Parameters:
  • hosts – list of uris; ES hosts to connect to, defaults to ['localhost:9200']
  • default_indexes – list of strings; the default indexes to use, defaults to ‘default’
  • timeout – int; the timeout in seconds, defaults to 5
  • dump_curl – function or None; function that dumps curl output, see docs, defaults to None
  • settings – other settings to pass into pyes.es.ES

Examples:

>>> es = get_es()
>>> es = get_es(hosts=['localhost:9200'])
>>> es = get_es(timeout=30)  # good for indexing
>>> es = get_es(default_indexes=['sumo_prod_20120627']
>>> class CurlDumper(object):
...     def write(self, text):
...         print text
...
>>> es = get_es(dump_curl=CurlDumper())

Warning

ElasticUtils works with pyes 0.15 and 0.16. The API for later versions of pyes has changed too much and won’t work with ElasticUtils. We’re planning to switch to something different in the future.

Project Versions

Previous topic

More like this with MLT

Next topic

Debugging

This Page