pandagg.tree.response module¶
-
class
pandagg.tree.response.
AggsResponseTree
(aggs, index)[source]¶ Bases:
pandagg.tree._tree.Tree
Tree representation of an ElasticSearch 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
-
parse
(raw_response)[source]¶ Build response tree from ElasticSearch aggregation response
Note: if the root aggregation node can generate multiple buckets, a response root is crafted to avoid having multiple roots.
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 sortingNode
objects in the same level - key – key used to order nodes of same parent
- 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
Return type: unicode in python2, str in python3
-