pandagg.tree.query.abstract module¶
-
class
pandagg.tree.query.abstract.
Compound
(**kwargs)[source]¶ Bases:
pandagg.tree.query.abstract.Query
-
KEY
= None¶
-
-
class
pandagg.tree.query.abstract.
Leaf
(*args, **kwargs)[source]¶ Bases:
pandagg.tree.query.abstract.Query
-
KEY
= None¶
-
-
class
pandagg.tree.query.abstract.
Query
(*args, **kwargs)[source]¶ Bases:
pandagg.tree._tree.Tree
Combination of query clauses.
Mapping declaration is optional, but doing so validates query validity and automatically inserts nested clauses when necessary.
Keyword Arguments: - mapping (
dict
orpandagg.tree.mapping.Mapping
) – Mapping of requested indice(s). Providing it will add validation features, and add required nested clauses if missing. - nested_autocorrect (
bool
) – In case of missing nested clauses in query, if True, automatically add missing nested clauses, else raise error. - remaining kwargs: Used as body in query clauses.
-
KEY
= None¶
-
node_class
¶
-
query
(*args, **kwargs)[source]¶ Insert new clause(s) in current query.
Inserted clause can accepts following syntaxes.
Given an empty query:
>>> from pandagg.query import Query >>> q = Query()
flat syntax: clause type, followed by query clause body as keyword arguments:
>>> q.query('term', some_field=23) {'term': {'some_field': 23}}
from regular Elasticsearch dict query:
>>> q.query({'term': {'some_field': 23}}) {'term': {'some_field': 23}}
using pandagg DSL:
>>> from pandagg.query import Term >>> q.query(Term(field=23)) {'term': {'some_field': 23}}
Keyword Arguments: - parent (
str
) – named query clause under which the inserted clauses should be placed. - parent_param (
str
optional parameter when using parent param) – parameter under which inserted clauses will be placed. For instance if parent clause is a boolean, can be ‘must’, ‘filter’, ‘should’, ‘must_not’. - child (
str
) – named query clause above which the inserted clauses should be placed. - child_param (
str
optional parameter when using parent param) – parameter of inserted boolean clause under which child clauses will be placed. For instance if inserted clause is a boolean, can be ‘must’, ‘filter’, ‘should’, ‘must_not’. - mode (
str
one of ‘add’, ‘replace’, ‘replace_all’) – merging strategy when inserting clauses on a existing compound clause.- ‘add’ (default) : adds new clauses keeping initial ones
- ‘replace’ : for each parameter (for instance in ‘bool’ case : ‘filter’, ‘must’, ‘must_not’, ‘should’), replace existing clauses under this parameter, by new ones only if declared in inserted compound query
- ‘replace_all’ : existing compound clause is completely replaced by the new one
- parent (
-
show
(*args, **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
- mapping (