Skip to main content

Lightweight python wrapper for elasticsearch.

Project description

A Python client for elasticsearch.

Usage

pyelasticsearch handles the low-level interactions with elasticsearch, allowing you to use native Python datatypes to index or perform queries.

Example:

conn = ElasticSearch('http://localhost:9200/')

# Index some documents.
conn.index({"name":"Joe Tester", "age": 25, "title": "QA Master"}, "contacts", "person", 1)
conn.index({"name":"Jessica Coder", "age": 32, "title": "Programmer"}, "contacts", "person", 2)
conn.index({"name":"Freddy Tester", "age": 29, "title": "Office Assistant"}, "contacts", "person", 3)

# Refresh the index to pick up the latest documents.
conn.refresh(["contacts"])

# Get just Jessica's document.
jessica = conn.get("contacts", "person", 2)

# Perform a simple search.
results = conn.search("name:joe OR name:freddy")

# Perform a search using the elasticsearch Query DSL (http://www.elasticsearch.org/guide/reference/query-dsl)
query = {
    "query_string": {
        "query": "name:tester"
    },
    "filtered": {
        "filter": {
            "range": {
                "age": {
                    "from": 27,
                    "to": 37,
                },
            },
        },
    },
}
results = conn.search(query)

# Clean up.
conn.delete_index("contacts")

For more examples, please check out the doctests & tests.py.

License

Licensed under the New BSD license.

Credits

Used pysolr as a jumping off point - thanks guys.

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.1.tar.gz (7.5 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pyelasticsearch-0.1.tar.gz
Algorithm Hash digest
SHA256 26e28cd9b30716c872e15b53a553e74082bc6cf7fcf5c9617e2ea8d022a51ae9
MD5 c25ef7b8eaa9de6cd9f436e1b3cfb5b7
BLAKE2b-256 eb97a185a98bb02abf04390294f97b853faa6f2dccf0659eff8602c44ad45448

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