Starting Traversal

.V([ids])

Start query from Vertex

O.query().V()

Returns all vertices in graph

O.query().V("vertex1")

Returns:

{"gid" : "vertex1", "label":"TestVertex", "data":{}}

.E()

Start query from Edge

O.query().E()

Returns all edges in graph

Filtering

.where()

Filter elements using conditional statements

O.query().V().where(aql.eq("_label", "Gene")).where(aql.eq("symbol", "TP53"))

Conditions

Conditions are arguments to .where() that define selection conditions

aql.eq(variable, value)

Returns rows where variable == value

.where(aql.eq("symbol", "TP53"))

aql.neq(variable, value)

Returns rows where variable != value

.where(aql.neq("symbol", "TP53"))

aql.gt(variable, value)

Returns rows where variable > value

.where(aql.gt("age", 45))

aql.lt(variable, value)

Returns rows where variable < value

.where(aql.lt("age", 45))

aql.gte(variable, value)

Returns rows where variable >= value

.where(aql.gte("age", 45))

aql.lte(variable, value)

Returns rows where variable <= value

.where(aql.lte("age", 45))

aql.in_(variable, value)

Returns rows where variable in value

.where(aql.in_("symbol", ["TP53", "BRCA1"]))

aql.contains(variable, value)

Returns rows where variable contains value

.where(aql.in_("groups", "group1"))

Returns:

{"data" : {"groups" : ["group1", "group2"]}}

aql.and_([conditions])

.where(aql.and_( [aql.lte("age", 45), aql.gte("age", 35)] ))

aql.or_([conditions])

.where(aql.or_( [...] ))

aql.not_(condition)

Output

.mark(name)

Store current row for future reference

O.query().V().mark("a").out().mark("b")

.select([names])

Output previously marked elements

.limit(count)

Limit number of total output rows

.offset(count)

Start return after offset

.render(template)

Render current selection into arbitrary data structure

Traversing the graph

.in_()

Following incoming edges. Optional argument is the edge label (or list of labels) that should be followed. If no argument is provided, all incoming edges.

.out()

Following outgoing edges. Optional argument is the edge label (or list of labels) that should be followed. If no argument is provided, all outgoing edges.

.both()

Following all edges (both in and out). Optional argument is the edge label (or list of labels) that should be followed.

.inEdge()

Following incoming edges, but return the edge as the next element. This can be used to inspect edge properties. Optional argument is the edge label (or list of labels) that should be followed. To return back to a vertex, use .in_ or .out

.outEdge()

Following outgoing edges, but return the edge as the next element. This can be used to inspect edge properties. Optional argument is the edge label (or list of labels) that should be followed. To return back to a vertex, use .in_ or .out

.bothEdge()

Following all edges, but return the edge as the next element. This can be used to inspect edge properties. Optional argument is the edge label (or list of labels) that should be followed. To return back to a vertex, use .in_ or .out

Aggregation

.aggregate()

Return aggregate counts of field. This can be run at the graph level, without using the .query() method to start a traversal, ie

O.aggregate(aql.term("test-agg", "Person", "name"))

Where test-agg is the name of the aggrigation, Person is the vertex label type and name is the field.

O.query().V("1").out().aggregate(aql.histogram("traversal-agg", "Person", "age", 5))

Starts on vertex 1, goes out and then creates a histogram named traversal-agg across the age field in the Person vertices.

.count()

Return the total count of elements

.distinct()

Only return distinct elements. Argument can JSON path to define what elements are used to identify uniqueness.