Fetching contributors…
Cannot retrieve contributors at this time
173 lines (96 sloc) 4.93 KB

API Documentation

A Word About Forward-Compatibility Kwargs

In the following documentation, the phrase "other kwargs listed below" refers to the kwargs documented in a subsequent Parameters section. However, it also implicitly includes any kwargs the caller might care to make up and have passed to ES as query string parameters. These kwargs must start with es_ for forward compatibility and will be unprefixed and converted to strings as discussed in :doc:`features`.

ElasticSearch Class

Unless otherwise indicated, methods return the JSON-decoded response sent by elasticsearch. This way, you don't lose any part of the return value, no matter how esoteric. But fear not: if there was an error, an exception will be raised, so it'll be hard to miss.

Bulk Indexing Methods

There's also a helper function, outside the ElasticSearch class:

Other Methods

Error Handling

Any method representing an ES API call can raise one of the following exceptions:


pyelasticsearch logs to the elasticsearch.trace logger using the Python logging module. If you configure that to show INFO-level messages, then it'll show the requests in curl form and their responses. To see when a server is marked as dead, follow the elasticsearch logger.

import logging



This assumes that logging is already set up with something like this:

import logging


pyelasticsearch will log lines like:

INFO:elasticsearch.trace: curl
-XGET 'http://localhost:9200/fooindex/testdoc/_search' -d '{"fa
cets": {"topics": {"terms": {"field": "topics"}}}}'

You can copy and paste the curl line, and it'll work on the command line.