Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.
/ ElasticQuery Public archive

A simple (Python) query builder for Elasticsearch

License

Notifications You must be signed in to change notification settings

Fizzadar/ElasticQuery

Repository files navigation

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 representation 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

About

A simple (Python) query builder for Elasticsearch

Resources

License

Stars

Watchers

Forks

Packages

No packages published