pandagg.node.agg.abstract module

class pandagg.node.agg.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 = NotImplementedError()
VALUE_ATTRS = NotImplementedError()
WHITELISTED_MAPPING_TYPES = None
classmethod deserialize(name, body, meta=None)[source]
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

query_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>] } ]?

}

tag

The readable node name for human. This attribute can be accessed and modified with . and = operator respectively.

classmethod valid_on_field_type(field_type)[source]
class pandagg.node.agg.abstract.BucketAggNode(name, meta=None, aggs=None, **body)[source]

Bases: pandagg.node.agg.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.agg import Terms, Avg >>> agg = Terms( >>> name=’term_agg’, >>> field=’some_path’, >>> aggs=[ >>> Avg(agg_name=’avg_agg’, field=’some_other_path’) >>> ] >>> ) Yet, the aggs attribute will then be reset to None to avoid confusion since the real hierarchy is stored in the bpointer/fpointer attributes inherited from treelib.Tree class.

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

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

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

Bases: pandagg.node.agg.abstract.MetricAgg

Metric aggregation based on single field.

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

Bases: pandagg.node.agg.abstract.AggNode

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

VALUE_ATTRS = NotImplementedError()
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.agg.abstract.MultipleBucketAgg(name, keyed=None, key_path='key', meta=None, aggs=None, **body)[source]

Bases: pandagg.node.agg.abstract.BucketAggNode

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

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

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

Bases: pandagg.node.agg.abstract.UniqueBucketAgg

VALUE_ATTRS = NotImplementedError()
get_filter(key)[source]

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

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

Bases: pandagg.node.agg.abstract.Pipeline

KEY = NotImplementedError()
VALUE_ATTRS = 'value'
class pandagg.node.agg.abstract.ShadowRoot[source]

Bases: pandagg.node.agg.abstract.BucketAggNode

Not a real aggregation.

KEY = 'shadow_root'
tag

The readable node name for human. This attribute can be accessed and modified with . and = operator respectively.

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

Bases: pandagg.node.agg.abstract.BucketAggNode

Aggregations providing a single bucket.

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

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