A simple query builder for Elasticsearch 2


License
Other
Install
pip install ElasticQuery==2.4

Documentation

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.

Synopsis

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


# Create a query with our ES index details
q = ElasticQuery(
    es=Elasticsearch(),
    index='mapping_test',
    doc_type='doc_mapping'
)

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

# Aggregate it!
q.aggregate(
    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()

Development/Testing

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