pandagg.tree.response module

class pandagg.tree.response.AggsResponseTree(aggs, raw_response=None)[source]

Bases: pandagg.tree._tree.Tree

Tree shaped representation of an ElasticSearch aggregations response.

bucket_properties(bucket, properties=None, end_level=None, depth=None)[source]

Recursive method returning a given bucket’s properties in the form of an ordered dictionnary. Travel from current bucket through all ancestors until reaching root.

Parameters:
  • bucket – instance of pandagg.buckets.buckets.Bucket
  • properties – OrderedDict accumulator of ‘level’ -> ‘key’
  • end_level – optional parameter to specify until which level properties are fetched
  • depth – optional parameter to specify a limit number of levels which are fetched
Returns:

OrderedDict of structure ‘level’ -> ‘key’

get_bucket_filter(nid)[source]

Build query filtering documents belonging to that bucket. Suppose the following configuration:

Base                        <- filter on base
  |── Nested_A                 no filter on A (nested still must be applied for children)
  |     |── SubNested A1
  |     └── SubNested A2    <- filter on A2
  └── Nested_B              <- filter on B
node_class

alias of pandagg.node.response.bucket.BucketNode

parse(raw_response)[source]

Build response tree from ElasticSearch aggregation response

Parameters:raw_response – ElasticSearch aggregation response
Returns:self
show(**kwargs)[source]

Return tree structure in hierarchy style.

Parameters:
  • nid – Node identifier from which tree traversal will start. If None tree root will be used
  • filter_ – filter function performed on nodes. Nodes excluded from filter function nor their children won’t be displayed
  • reverse – the reverse param for sorting Node objects in the same level
  • display_key – boolean, if True display keyed nodes keys
  • reverse – reverse parameter applied at sorting
  • line_type – display type choice
  • limit – int, truncate tree display to this number of lines
  • kwargs – kwargs params passed to node line_repr method

:param line_max_length :rtype: unicode in python2, str in python3