ESEngine¶
ESEngine is an ODM (Object Document Mapper) it maps Python classes in to Elasticsearch index/doc_type and object instances() in to Elasticsearch documents and also provides a Pythonic query builder.
Install with pip install esengine
Payload¶
The main Payload
class allows you to build Elasticsearch queries
from esngine import Payload, Query, Aggregate
# Create a new payload
p = Payload()
# Match something
p.query(Query.match('some_field', 'some_text'))
# Aggregate something
p.aggregate(Aggregate.terms('my_terms', 'some_field'))
API¶
Exceptions¶
Queries¶
Note that all Query calls can also be passed additional keyword arguments not specified here, but no validation of inputs is done on them.
Query.span_or¶
Query.span_or([Query])
Query.terms¶
Query.terms(field, [value])
Query.has_child¶
Query.has_child(type, filter=Filter, query=Query)
Query.span_first¶
Query.span_first(Query)
Query.prefix¶
Query.prefix(field, value, boost=None)
Query.term¶
Query.term(field, value, boost=None)
Query.fuzzy¶
Query.fuzzy(field, value, boost=None, fuzziness=None, prefix_length=None, max_expansions=None)
Query.nested¶
Query.nested(path, Query)
Query.dis_max¶
Query.dis_max([Query])
Query.query_string¶
Query.query_string(query, fields=[])
Query.fuzzy_like_this¶
Query.fuzzy_like_this([fields], like_text)
Query.has_parent¶
Query.has_parent(parent_type, filter=Filter, query=Query)
Query.function_score¶
Query.function_score([functions], filter=Filter, query=Query)
Query.geo_shape¶
Query.geo_shape(field, type=None, coordinates=[])
Query.fuzzy_like_this_field¶
Query.fuzzy_like_this_field(field, like_text, max_query_terms=None, ignore_tf=None, fuzziness=None, prefix_length=None, boost=None, analyzer=None)
Query.span_multi¶
Query.span_multi(Query)
Query.match_all¶
Query.match_all(boost=None)
Query.span_near¶
Query.span_near([Query])
Query.simple_query_string¶
Query.simple_query_string(query, fields=[])
Query.multi_match¶
Query.multi_match([fields], query)
Query.span_term¶
Query.span_term(field, value, boost=None)
Query.regexp¶
Query.regexp(field, value, boost=None, flags=None)
Query.ids¶
Query.ids([values], type=None)
Query.more_like_this¶
Query.more_like_this([fields], like_text)
Query.range¶
Query.range(field, gte=None, gt=None, lte=None, lt=None)
Query.bool¶
Query.bool(must=[Query], must_not=[Query], should=[Query])
Query.common¶
Query.common(query)
Query.wildcard¶
Query.wildcard(field, value, boost=None)
Query.indices¶
Query.indices([indices], query=Query, no_match_query=Query)
Query.filtered¶
Query.filtered(filter=Filter, query=Query)
Query.span_not¶
Query.span_not(include=Query, exclude=Query)
Query.boost¶
Query.boost(positive=None, negative=None)
Query.constant_score¶
Query.constant_score(filter=Filter, query=Query)
Query.match¶
Query.match(field, query, operator=None, zero_terms_query=None, cutoff_frequency=None, boost=None)
Query.top_children¶
Query.top_children(type, query=Query)
Aggregates¶
Note that all Aggregate calls can also be passed additional keyword arguments not specified here, but no validation of inputs is done on them.
Aggregate.geo_bounds¶
Aggregate.geo_bounds(name, field)
Aggregate.date_histogram¶
Aggregate.date_histogram(name, field, interval)
Aggregate.global¶
Aggregate.global(name)
Aggregate.nested¶
Aggregate.nested(name, path)
Aggregate.ip_range¶
Aggregate.ip_range(name, field, [ranges])
Aggregate.filters¶
Aggregate.filters(name, [Filter])
Aggregate.avg¶
Aggregate.avg(name, field)
Aggregate.children¶
Aggregate.children(name, type)
Aggregate.stats¶
Aggregate.stats(name, field)
Aggregate.scripted_metric¶
Aggregate.scripted_metric(name)
Aggregate.min¶
Aggregate.min(name, field)
Aggregate.sum¶
Aggregate.sum(name, field)
Aggregate.extended_stats¶
Aggregate.extended_stats(name, field)
Aggregate.value_count¶
Aggregate.value_count(name, field)
Aggregate.percentiles¶
Aggregate.percentiles(name, field)
Aggregate.terms¶
Aggregate.terms(name, field)
Aggregate.missing¶
Aggregate.missing(name, field)
Aggregate.max¶
Aggregate.max(name, field)
Aggregate.histogram¶
Aggregate.histogram(name, field, interval)
Aggregate.date_range¶
Aggregate.date_range(name, field, [ranges])
Aggregate.cardinality¶
Aggregate.cardinality(name, field)
Aggregate.geohash_grid¶
Aggregate.geohash_grid(name, field)
Aggregate.geo_distance¶
Aggregate.geo_distance(name, field, origin, [ranges])
Aggregate.filter¶
Aggregate.filter(name, Filter)
Aggregate.percentile_ranks¶
Aggregate.percentile_ranks(name, field)
Aggregate.range¶
Aggregate.range(name, field, [ranges])
Aggregate.significant_terms¶
Aggregate.significant_terms(name, field)
Aggregate.top_hits¶
Aggregate.top_hits(name)
Aggregate.reverse_nested¶
Aggregate.reverse_nested(name)
Suggesters¶
Note that all Suggester calls can also be passed additional keyword arguments not specified here, but no validation of inputs is done on them.
Suggester.completion¶
Suggester.completion(field, size=None)
Suggester.phrase¶
Suggester.phrase(field, gram_size=None, real_word_error_likelihood=None, confidence=None, max_errors=None, separator=None, size=None, analyzer=None, shard_size=None, collate=None)
Suggester.term¶
Suggester.term(field, analyzer=None, size=None, sort=None, suggest_mode=None)
Filters¶
Note that all Filter calls can also be passed additional keyword arguments not specified here, but no validation of inputs is done on them.
Filter.geohash_shell¶
Filter.geohash_shell(field, lat=None, lon=None)
Filter.geo_polygon¶
Filter.geo_polygon(field, [points])
Filter.exists¶
Filter.exists(field)
Filter.not_¶
Filter.not_(filter=Filter, query=Query)
Filter.nested¶
Filter.nested(path, Filter)
Filter.prefix¶
Filter.prefix(field, value)
Filter.has_parent¶
Filter.has_parent(parent_type, filter=Filter, query=Query)
Filter.geo_distance_range¶
Filter.geo_distance_range(field, lat=None, lon=None)
Filter.script¶
Filter.script(script)
Filter.bool¶
Filter.bool(must=[Filter], must_not=[Filter], should=[Filter])
Filter.type¶
Filter.type(value)
Filter.terms¶
Filter.terms(field, [value])
Filter.has_child¶
Filter.has_child(type, filter=Filter, query=Query)
Filter.missing¶
Filter.missing(field)
Filter.term¶
Filter.term(field, value)
Filter.geo_shape¶
Filter.geo_shape(field, type=None, coordinates=[])
Filter.regexp¶
Filter.regexp(field, value, flags=None, max_determinized_states=None)
Filter.or_¶
Filter.or_([Filter])
Filter.match_all¶
Filter.match_all(None)
Filter.geo_distance¶
Filter.geo_distance(field, lat=None, lon=None)
Filter.geo_bounding_box¶
Filter.geo_bounding_box(field, top_left=None, bottom_right=None)
Filter.and_¶
Filter.and_([Filter])
Filter.ids¶
Filter.ids([values], type=None)
Filter.range¶
Filter.range(field, gte=None, gt=None, lte=None, lt=None)
Filter.limit¶
Filter.limit(value)
Filter.indices¶
Filter.indices([indices], filter=Filter, no_match_filter=Filter)
Credits¶
This library is created and maintained by http://catholabs.com/authors/ team
A lot of Open Source software were used to develop and inspire this project:
- PyCharm (IDE)
- Py.Test (test suit)
- TravisCI (Continuous Integration)
- Landscape.io (Code Quality Assurance)
- Elasticsearch-py (Base Client)
- Elasticsearch-dsl (inspiration for models)
- ElasticQuery by “Nick Barrett/@Fizzadar” (inspiration for query builder)