ElasticQuery Client

The main ElasticQuery class allows you to build Elasticsearch queries using a Pythonic API:

from elasticquery import ElasticQuery, Query, Aggregate

# Create a new query
q = ElasticQuery()

# Match something
q.query(Query.match('some_field', 'some_text'))

# Aggregate something
q.aggregate(Aggregate.terms('my_terms', 'some_field'))

API

class elasticquery.elasticquery.ElasticQuery(es=None, index=None, doc_type=None)

A class for building ES queries.

aggregate(*aggregates)

Add one or more aggregates to this query.

dict()

Returns the current query in dict format.

fields(fields)

Set the fields/_source for this query.

from_(from_)

Set the from/offset for this query.

get()

Execute the current query (requires _es, _index & _doc_type).

json(**kwargs)

Returns a JSON representation of the current query. Kwargs are passed to json.dumps.

query(query)

Set the query for this query.

set(key, value)

Set an arbitrary attribute on this query.

size(size)

Set the size of this query.

sort(field, order=None)

Sort this query.

suggest(*suggesters)

Add one or more suggesters to this query.

timeout(timeout)

Set the timeout for this query.

Exceptions

exception elasticquery.exceptions.MissingArgError
exception elasticquery.exceptions.NoAggregateError
exception elasticquery.exceptions.NoQueryError
exception elasticquery.exceptions.NoSuggesterError
exception elasticquery.exceptions.QueryError