pandagg.tree.response module¶
-
class
pandagg.tree.response.
ResponseTree
(agg_tree, identifier=None)[source]¶ Bases:
pandagg.tree._tree.Tree
Tree representation of an ES response. ES response format is determined by the aggregation query.
-
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. :param bucket: instance of pandagg.buckets.buckets.Bucket :param properties: OrderedDict accumulator of ‘level’ -> ‘key’ :param end_level: optional parameter to specify until which level properties are fetched :param depth: optional parameter to specify a limit number of levels which are fetched :return: OrderedDict of structure ‘level’ -> ‘key’
-
get_bucket_filter
(nid)[source]¶ Build query filtering documents belonging to that bucket. Suppose the following configuration:
-
parse_aggregation
(raw_response)[source]¶ Build response tree from ES response :param raw_response: ES aggregation response :return: self
Note: if the root aggregation node can generate multiple buckets, a response root is crafted to avoid having multiple roots.
-
show
(data_property='pretty', **kwargs)[source]¶ Print the tree structure in hierarchy style.
You have three ways to output your tree data, i.e., stdout with
show()
, plain text file withsave2file()
, and json string withto_json()
. The former two use the same backend to generate a string of tree structure in a text graph.- Version >= 1.2.7a*: you can also specify the
line_type
parameter, such as ‘ascii’ (default), ‘ascii-ex’, ‘ascii-exr’, ‘ascii-em’, ‘ascii-emv’, ‘ascii-emh’) to the change graphical form.
Parameters: - nid – the reference node to start expanding.
- level – the node level in the tree (root as level 0).
- idhidden – whether hiding the node ID when printing.
- filter – the function of one variable to act on the
Node
object. When this parameter is specified, the traversing will not continue to following children of node whose condition does not pass the filter. - key – the
key
param for sortingNode
objects in the same level. - reverse – the
reverse
param for sortingNode
objects in the same level. - line_type –
- data_property – the property on the node data object to be printed.
Returns: None
- Version >= 1.2.7a*: you can also specify the
-