pandagg.node.aggs.abstract module

class pandagg.node.aggs.abstract.AggNode(name, meta=None, **body)[source]

Bases: pandagg.node._node.Node

Wrapper around elasticsearch aggregation concept. https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations.html

Each aggregation can be seen both a Node that can be encapsulated in a parent agg.

Define a method to build aggregation request.

BLACKLISTED_MAPPING_TYPES = None
KEY = None
VALUE_ATTRS = None
WHITELISTED_MAPPING_TYPES = None
classmethod extract_bucket_value(response, value_as_dict=False)[source]
extract_buckets(response_value)[source]
get_filter(key)[source]

Return filter query to list documents having this aggregation key. :param key: string :return: elasticsearch filter query

line_repr(depth, **kwargs)[source]

Control how node is displayed in tree representation.

to_dict(with_name=False)[source]

ElasticSearch aggregation queries follow this formatting:

{
    "<aggregation_name>" : {
        "<aggregation_type>" : {
            <aggregation_body>
        }
        [,"meta" : {  [<meta_data_body>] } ]?
    }
}

Query dict returns the following part (without aggregation name):

{
    "<aggregation_type>" : {
        <aggregation_body>
    }
    [,"meta" : {  [<meta_data_body>] } ]?
}
classmethod valid_on_field_type(field_type)[source]
class pandagg.node.aggs.abstract.BucketAggNode(name, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.AggNode

Bucket aggregation have special abilities: they can encapsulate other aggregations as children. Each time, the extracted value is a ‘doc_count’.

Provide methods: - to build aggregation request (with children aggregations) - to to extract buckets from raw response - to build query to filter documents belonging to that bucket

Note: the aggs attribute’s only purpose is for children initiation with the following syntax: >>> from pandagg.aggs import Terms, Avg >>> agg = Terms( >>> name=’term_agg’, >>> field=’some_path’, >>> aggs=[ >>> Avg(agg_name=’avg_agg’, field=’some_other_path’) >>> ] >>> )

VALUE_ATTRS = None
extract_buckets(response_value)[source]
get_filter(key)[source]

Provide filter to get documents belonging to document of given key.

class pandagg.node.aggs.abstract.FieldOrScriptMetricAgg(name, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.MetricAgg

Metric aggregation based on single field.

VALUE_ATTRS = None
class pandagg.node.aggs.abstract.MetricAgg(name, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.AggNode

Metric aggregation are aggregations providing a single bucket, with value attributes to be extracted.

VALUE_ATTRS = None
extract_buckets(response_value)[source]
get_filter(key)[source]

Return filter query to list documents having this aggregation key. :param key: string :return: elasticsearch filter query

class pandagg.node.aggs.abstract.MultipleBucketAgg(name, keyed=None, key_path='key', meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.BucketAggNode

IMPLICIT_KEYED = False
VALUE_ATTRS = None
extract_buckets(response_value)[source]
get_filter(key)[source]

Provide filter to get documents belonging to document of given key.

class pandagg.node.aggs.abstract.Pipeline(name, buckets_path, gap_policy=None, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.UniqueBucketAgg

VALUE_ATTRS = None
get_filter(key)[source]

Provide filter to get documents belonging to document of given key.

class pandagg.node.aggs.abstract.ScriptPipeline(name, script, buckets_path, gap_policy=None, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.Pipeline

KEY = None
VALUE_ATTRS = 'value'
class pandagg.node.aggs.abstract.ShadowRoot[source]

Bases: pandagg.node.aggs.abstract.UniqueBucketAgg

Not a real aggregation.

KEY = 'shadow_root'
classmethod extract_bucket_value(response, value_as_dict=False)[source]
get_filter(key)[source]

Provide filter to get documents belonging to document of given key.

line_repr(depth, **kwargs)[source]

Control how node is displayed in tree representation.

class pandagg.node.aggs.abstract.UniqueBucketAgg(name, meta=None, **body)[source]

Bases: pandagg.node.aggs.abstract.BucketAggNode

Aggregations providing a single bucket.

VALUE_ATTRS = None
extract_buckets(response_value)[source]
get_filter(key)[source]

Provide filter to get documents belonging to document of given key.