MATCH, CREATE, property filters, procedures, and available data types.
Basics
Queries are built by referencing nodes and edges. TuringDB supports the standard CYPHER syntax, in that nodes are denoted using parentheses(), whilst edges are denoted using square brackets [].
For example, (n) would denote a node named n, whilst [e] would denote an edge named e.
Nodes and edges can have both label and property constraints. As in standard CYPHER, property constraints are specified using curly brackets {}, whilst labels are specified using colon : syntax.
An example of a node with a label constraint would be (n:Person).
An example of an edge with a property constraint would be [e {duration: 10}].
Property and label constraints may be combined, for instance, (n:Person {name: 'John'}) specifies a node which both has the label Person, and a name property with the value John.
Nodes and edges can have label and property multiple constraints, which are specified in a comma-separated list: (n:Person:Man {name: 'John', age: 20}). These lists can be arbitrarily long.
By convention:
- we prefer using single quotes around strings (even if double quotes alsowork )
- node label are written in Pascal case (no spaces): e.g.
Person,BankAccount,BloodType - edge label are written in upper case (spaces replaced by underscores): e.g.
TRANSACTION,FRIENDS_WITH,IS_CLIENT_OF
Summary:
Queries are built around nodes and edges:- Nodes are written in parentheses
()e.g.(n)- a node with aliasn - Edges are written in square brackets
[]e.g.[e]- an edge with aliase
- Labels with a colon
:- e.g.(n:Person) - Property constraints with curly braces
{}- e.g.[e {duration: 10}] - Both at once - e.g.
(n:Person {name: 'John'})
Queries
Queries are built up of combinations of nodes and edges, as specified above.MATCH queries
MATCH queries are used to retrieve nodes, edges, and their property values from the database via specification of relationships and properties.
It is easiest to demonstrate the syntax of a MATCH query with a concrete example:
n.
MATCH queries are flexible: they can contain a single node and no edges, or any number of node, edge pairs. For example:
MATCH query would be:
Queries have variables, which in the above examples are those such as Both node and edges can omit a variable name if they specify at least a label constraint:
n, m, e, etc. Variables are a way to give a name to a node or an edge, so that those nodes or edges can be specified in the RETURN clause. However, if you do not want to return an edge or its properties, the edge need not have a name. For example:MATCH queries, and the ability to specify constraints, here are a few examples of some syntactically correct TuringDB MATCH queries:
MATCH (n:Person) RETURN n.nameMATCH (:Person)-->(n:Person) RETURN n.nameMATCH (n:Person:Woman:SoftwareEngineer) RETURN n.nameMATCH (n:Person:Woman:SoftwareEngineer)-->(m)-[e]->(p:Man)-[f]->(q) RETURN e, f
CREATE queries
CREATE queries follow exactly the same syntax as MATCH queries when it comes to specifying nodes, edges, and property/label constraints. CREATE queries may have RETURN clauses, but they do not need them. There is also the additional requirement that all nodes and edges must have at least one label. This means a query such as
MATCH ... CREATE ... and MATCH ... CREATE ... RETURN ... queries
MATCH, CREATE and RETURN statements can be used together in queries.
For example, to create a edge between two existing graph, the following queries can be used:
WHERE queries
The WHERE clause allows to filter the results on node and/or edge labels and/or properties.
To filter on node label:
Multi-pattern queries (Joins and Cartesian Products)
TuringDB supports matching multiple patterns in a single query by separating them with commas. Depending on whether the patterns share variables, this results in either a join or a cartesian product.Cartesian Product
When patterns in aMATCH clause are separated by commas and do not share any variables, TuringDB computes a cartesian product of the results. Every row from the first pattern is combined with every row from the second.
WHERE to filter the cartesian product:
Pattern-based Joins
When two paths converge on a shared node variable, TuringDB performs a hash join on that variable. This is useful for finding entities that share a common connection.b acts as the join point.
Multi-hop joins are also supported:
Mixing Paths and Cartesian Products
Connected paths and independent patterns can be combined in the same query. Shared variables create joins, while unrelated patterns create cartesian products.LIMIT keyword
LIMIT restricts the number of returned results. The following query returns only the first 10 results:
SKIP keyword
SKIP skips the first N results before returning the rest. The following query skips the first 10 results:
SKIP and LIMIT can be combined for pagination. The following query will return the 11th to 20th results:
Sorting with ORDER BY
ORDER BY sorts the results by one or more properties. By default, results are sorted in ascending order.
DESC to sort in descending order:
ORDER BY can be combined with SKIP and LIMIT for sorted pagination:
Data Types
TuringDB offers the following data types for node and edge properties:- String
- Boolean
- Integer (signed)
- Double (decimal)
- Embedding (vector of floats, e.g.
(1.2, 2.0, 0.0))
"), single quotes ('), or backticks (```).
Operators
Boolean operators
TheOR and AND operartors are used to filter on multiple conditions:
Comparison operators
TuringDB allows you to query against node and edge properties using the: operator for exact matching of the property value.
-
Equal:
= -
Inequal:
<> -
Less than:
< -
Less than or equal to:
<= -
Greater than:
> -
Greater than or equal to:
>= -
is null:
IS NULL -
is not null:
IS NOT NULL
Expression Evaluation in RETURN
Since v1.22.0, TuringDB supports arithmetic expressions directly inRETURN projections.
Supported operators: +, -, *, /
Built-in Functions
TuringDB supports built-in functions for type conversion, introspection, and embedding comparison.Introspection: labels(), edgeType()
Type conversion: toInteger(), toFloat(), toBoolean()
Embedding comparison: cosine_similarity(), euclidean_distance()
Compare two embeddings (embedding literals use parentheses — see Vector Search):
Aggregation: count(), avg()
TuringDB supports the count() and avg() aggregating functions. Aggregates may only be used when the query has a single return item:
Procedures
On top of supporting queries which return or alter information in the graph, TuringDB supports a number of procedures which return information, or metadata, about the graph. These queries follow theCALL syntax, and the following variants are supported:
CALL db.propertyTypes()- all node and edge property keys and their typesCALL db.labels()- all node labelsCALL db.edgeTypes()- all edge types (edge equivalent of node labels)CALL db.history()- the commit history (commit, nodeCount, edgeCount, partCount)CALL db.describeCommit('<hash>')- node/edge/part counts for a single commitCALL db.procedures()- list the available procedures and their signaturesCALL db.showIndexes()- list property indexes and their sizes
MATCH queries.
A procedure’s output columns can be YIELDed and fed into a following MATCH/WHERE:
Commands
Outside of CYPHER, there are a number of commands which you can use to interact with the TuringDB engine.| Command | Explanation |
|---|---|
CREATE GRAPH <graph name> | Create a graph with the specified name |
LOAD GRAPH <graph name> | Load the specified TuringDB graph. Requires the graph files to be accessible in TuringDB directory (-turing-dir, graphs subdir) |
LOAD GML 'mygraph.gml' AS my_graph | Load the specified GML as TuringDB graph. Requires the GML to be accessible in TuringDB directory (-turing-dir, data subdir) |
LOAD JSONL 'mygraph.jsonl' AS my_graph | Load the specified JSONL as TuringDB graph. Requires the JSONL to be accessible in TuringDB directory (-turing-dir, data subdir) |
LOAD JSONL 'mygraph.jsonl' AS my_graph WITH EMBEDDINGS [{"emb", 384}] | Load JSONL and mark array properties as embeddings (see JSONL import) |
COMMIT | Persist intermediate state within a change (needed between separate node and edge create steps) |
CHANGE NEW | Creates a new change, returning a column with the ID of the created change |
CHANGE SUBMIT | When checked out on a specific change, submits all changes made to the “master branch” |
CHANGE DELETE | Deletes the currently checked out change |
CHANGE LIST | Lists the currently active (uncommitted) changes |
LOAD COMMIT '<hash>' | Load a past commit into memory for querying. Required when sending queries directly to the REST API for non-HEAD commits. The CLI checkout and Python SDK handle this automatically. |
LIST GRAPH | Lists the available graphs |
CREATE VECTOR INDEX <name> WITH DIMENSION <n> METRIC <COSINE|EUCLID> | Create a vector index (see Vector Search) |
VECTOR SEARCH IN <index> FOR <k> (<vec>) YIELD ids | k-nearest-neighbor search over a vector index |
CREATE INDEX <name> FOR (n) ON n.prop | Create a property index on a node property (write — see Indexes below) |
CREATE INDEX <name> FOR [e] ON e.prop | Create a property index on an edge property |
DROP INDEX <name> | Drop a property or vector index by name |
MERGE_DATAPARTS | Compact all DataParts of the current graph into one (see DataParts) |
INSTALL <extension> | Load a procedure extension (see Extensions below) |
SHOW EXTENSIONS | List installed extensions |
SHOW PROCEDURES | List available procedures and signatures (same data as CALL db.procedures()) |
UNWIND
UNWIND expands a list into one row per element. It is a reading statement and composes with RETURN / MATCH.
Property Indexes
A property index speeds up equality lookups on a node or edge property. The query optimizer automatically rewritesWHERE n.prop = <value> into an index lookup when a matching index exists.
Creating an index is a write, so it must run inside a change and only takes effect after the change is committed/submitted:
CALL db.showIndexes() (yields name, size); remove one with DROP INDEX age_index.
Extensions
Extensions are native shared libraries that register extra procedure namespaces callable viaCALL. Install one by name, then call its procedures:
SHOW PROCEDURES lists every available procedure and its signature (the same information as CALL db.procedures()).

