A simple (Python) query builder for Elasticsearch
Python Shell
Clone or download
Latest commit 70b4a25 Jun 6, 2018
Failed to load latest commit information.
docs v3.1. Apr 1, 2016
elasticquery Linting! Jun 6, 2018
scripts Linting! Jun 6, 2018
tests Linting! Jun 6, 2018
.gitignore Move docs -> rst Nov 26, 2015
CHANGELOG.md Version bumps. Jun 6, 2018
LICENSE.md license year/email Jul 18, 2015
README.md Merge pull request #19 from arne-cl/patch-1 Apr 7, 2018
requirements.pip Exceptions refactored, more tests, v3 prep. Jan 31, 2016
setup.cfg Linting! Jun 6, 2018
setup.py Version bumps. Jun 6, 2018


ElasticQuery v3 PyPI version

A simple query builder for Elasticsearch. Install with pip install elasticquery. Uses metod calls and their args/kwargs to generate query/filter/aggregate objects. Outputs dict/json represntation to be passed directly to ES.


from elasticsearch import Elasticsearch
from elasticquery import ElasticQuery, Filter, Aggregate

# Create a query with our ES index details
q = ElasticQuery(

# Query it!
    Query.terms('my_field', ['my', 'terms'])

# Aggregate it!
    Aggregate.sum('my_agg', 'my_field')

# Print the query, then run on ES and print it's output
print q.json(indent=4)
print q.get()


  • Create virtualenv
  • pip install -r requirements.pip
  • Run nosetests