Skip to main content

Lightweight python wrapper for elasticsearch.

Project description

Build Status

pyelasticsearch is a clean, future-proof, high-scale API to elasticsearch. It provides features like…

  • Transparent conversion of Python data types to and from JSON

  • Connection pooling

  • Load balancing of requests across nodes in a cluster

  • Failed-node marking to avoid downed nodes for a period

  • Optional automatic retrying of failed requests

Full documentation: http://pyelasticsearch.readthedocs.org/


v0.2 (2012-10-06)

Many thanks to Erik Rose for almost completely rewriting the API to follow best practices, improve the API user experience and making pyelasticsearch future-proof.

Backward-incompatible changes:

  • search() and count() no longer take the query-string-dwelling query (if any) as an arg. Now each simply takes either a textual or a dict query as its first argument. There’s no more silliness about needing to use either a q or a body kwarg. This means callers no longer have to pass an empty string as the first arg when they want to use a JSON query (a very common case).

  • Standardized on the singular for the names of the index and doc_type kwargs. It’s not always obvious whether an ES API allows for multiple indexes. This was leading me to have to look aside to the docs to determine whether the kwarg was called index or indexes. Using the singular everywhere will result in fewer doc lookups, especially for the common case of a single index.

  • Renamed morelikethis to more_like_this for consistency with other methods.

  • index() now takes (index, doc_type, doc) rather than (doc, index, doc_type), for consistency with bulk_index() and other methods.

  • Similarly, put_mapping() now takes (index, doc_type, mapping) rather than (doc_type, mapping, index).

  • To prevent callers from accidentally destroying large amounts of data…

    • delete() no longer deletes all documents of a doctype when no ID is specified; use delete_all() instead.

    • delete_index() no longer deletes all indexes when none are given; use delete_all_indexes() instead.

    • update_settings() no longer updates the settings of all indexes when none are specified; use update_all_settings() instead.

  • setup_logging() is gone. If you want to configure logging, use the logging module’s usual ways. We still log to the “pyelasticsearch” named logger.

  • Rethink error handling:

    • Raise a more specific exception for HTTP error codes so callers can catch it without examining a string.

    • Catch non-JSON responses properly, and raise the more specific NonJsonResponseError instead of the generic ElasticSearchError.

    • Remove mentions of nonexistent exception types that would cause crashes in their except clauses.

    • Crash harder if JSON encoding fails: that always indicates a bug in pyelasticsearch.

    • Remove the ill-defined ElasticSearchError.

    • Raise ConnectionError rather than ElasticSearchError if we can’t connect to a node (and we’re out of auto-retries).

    • Raise ValueError rather than ElasticSearchError if no documents are passed to bulk_index.

    • All exceptions are now more introspectable, because they don’t immediately mash all the context down into a string. For example, you can recover the unmolested response object from ElasticHttpError.

    • Removed quiet kwarg, meaning we always expose errors.

Other changes:

  • Add Sphinx documentation.

  • Add load-balancing across multiple nodes.

  • Add failover in the case where a node doesn’t respond.

  • Add close_index, open_index, update_settings, health.

  • Support passing arbitrary kwargs through to the ES query string. Known ones are taken verbatim; unanticipated ones need an “es_” prefix to guarantee forward compatibility.

  • Automatically convert datetime objects when encoding JSON.

  • Recognize and convert datetimes and dates in pass-through kwargs. This is useful for timeout.

  • In routines that can take either one or many indexes, don’t require the caller to wrap a single index name in a list.

  • Many other internal improvements

v0.1 (2012-08-30)

Initial release based on the work of Robert Eanes and other the other authors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyelasticsearch-0.2.tar.gz (29.0 kB view details)

Uploaded Source

File details

Details for the file pyelasticsearch-0.2.tar.gz.

File metadata

  • Download URL: pyelasticsearch-0.2.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyelasticsearch-0.2.tar.gz
Algorithm Hash digest
SHA256 7ec56f072184c390cf76d52262ff05bc5664fc93dce2c995a98aad68a0a66ad7
MD5 1af87604b5fe73923e22c43ae0e30c6d
BLAKE2b-256 85aa38033ff6dd32055a148273a7d47b3217a6812ff031762d87ef379dd5e30f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page