-
Notifications
You must be signed in to change notification settings - Fork 4
Query API
Create complex ElasticSearch queries. Returns a graphit.EESQuery instance that can be passed to graphit.GraphitSession.query() or used as a sub–clause in another query.
-
*clauses:Arbitrary number of query clauses, either astrcontaining a valid ElasticSearch query string or another instance ofEESQuery. -
operation: The logical operation by that the clauses should be linked, one of
"AND"(default),"OR"or"NOT"(in case of multiple clause,"NOT"will be translated toNOT ( clause1 OR clause2 OR ...))
Add additional clauses to an existing Query.
-
*clauses:Arbitrary number of query clauses, either astrcontaining a valid ElasticSearch query string or another instance ofEESQuery.⚠️ Opposed to the direct use ofgraphit.GraphitSession.query(), there is no need to escape characters like/, in fact that would lead to an invalid query.
Remove all clauses from an existing Query.
Render the EESQuery object, returns the final query string as str, so it can be passed to the query method of a GraphitSession
Create Gremlin queries. Returns a graphit.GremlinQuery instance that can be passed to graphit.GraphitSession.query().
-
root: Starting point of the graph traversal, astrcontaining a validogit/_id. -
query: Astrcontaining a valid Gremlin query string.
Create a simple "verb" query that returns the nodes that are connected to a certain node by a specific verb. Returns a graphit.VerbQuery instance that can be passed to graphit.GraphitSession.query().
-
root: Starting point of the query, astrcontaining a validogit/_id. -
verb: Astrcontaining a validogit/_typefor verbs/edges. -
ogit_types: Alist(or other iterable) ofstrcontaining a validogit/_typefor nodes/vertices. Limits the result set to nodes of these types. -
direction: One of"in","out"or"both"(default), return only nodes that are connected by incoming or outgoing edges or return all connected nodes, respectively.
Create a Multi-ID query. Returns a graphit.IDQuery instance that can be passed to graphit.GraphitSession.query().
-
*node_ids: Arbitrary number ofstrcontaining anogit/_id.
q1 = graphit.EESQuery(
'ogit/_type:"ogit/BusinessProcess/DataObject"',
'ogit/_owner:"arago.de"'
)
print(q1)
( ogit\/_type:"ogit\/BusinessProcess\/DataObject" AND ogit\/_owner:"arago.de" )
q1.append('ogit/_modified-on:[now-7d TO now]')
print(q1)
( ogit\/_type:"ogit\/BusinessProcess\/DataObject" AND ogit\/_owner:"arago.de" AND ogit\/_modified\-on:[now\-7d TO now] )
q2 = graphit.EESQuery('ogit/_id:"cjkmq4st02xseyd33qkutr6ut"', q1, operation='OR')
print(q2)
( ogit\/_id:"cjkmq4st02xseyd33qkutr6ut" OR ( ogit\/_type:"ogit\/BusinessProcess\/DataObject" AND ogit\/_owner:"arago.de" AND ogit\/_modified\-on:[now\-7d TO now] ) )
for item in session.query(q2, limit=1000, fields=['ogit/_id', '/MyCustomAttribute']):
do_something(item)q3 = graphit.GremlinQuery(
root="cjkmq4st02xseyd33qkutr6ut",
query="inE('ogit/uses').has('ogit/_out-type','ogit/BusinessProcess/DataObject').outV()"
)
for item in session.query(q3):
do_something(item)q4 = graphit.VerbQuery(
root="cjkmq4st02xseyd33qkutr6ut",
verb="ogit/uses",
ogit_types=["ogit/Business/DataObject"],
direction="in"
)
for item in session.query(q4):
do_something(item)