OTQL
The Object Tree Query Language: what it is for, and how a query is put together.
Your goal
Write queries against the whole object graph - to count, to explore, and to define segments.
Expected outcome
Queries that return the population you meant, on a graph of millions or billions of objects.
What OTQL is
The Object Tree Query Language is designed to search and calculate aggregates on a large collection of object trees. The object tree is defined in your schema by the @TreeIndexRoot and @TreeIndex directives.
An OTQL query looks like SQL:
SELECT { id name } FROM Product WHERE price > 50.0It has these parts:
SELECT [Operation] FROM [Object Type] WHERE [Object Tree Expression]SELECT operation
What to do: extract field values, or calculate aggregates.
FROM starting object type
The object type the evaluation starts from.
WHERE object tree expression
A logical expression mixing boolean operators and field operators, connecting objects in the tree.
The kinds of operation are:
Selection operations are similar to a GraphQL operation, and return a list of objects containing the required fields.
Aggregation operations return aggregated values - counts, statistics, histograms - calculated on the selected objects.
What a query looks like in practice
The full language - operators, scoring, aggregations, joins, limits - is in OTQL documentation, and more worked queries are in OTQL examples.
Where to start from
Given this object tree:
you can start a query from any of those types, and the equivalent forms are worth knowing:
The choice of starting type changes what a count counts: FROM UserPoint counts people, FROM UserEvent counts events.
Where you write OTQL
Query Tool, in Data Studio
Interactive exploration. See Query Tool.
Segment definitions
A USER_QUERY segment is an OTQL query.
The Query API
Saved queries, executed programmatically. See Query API.
Segment metrics
Each metric is an OTQL query returning a number. See Segment metrics.
Query exports
An export is built on a saved query. See Export.
Dashboards
Cards are backed by queries. See Create a custom dashboard.
In this section
Related pages
Last updated
Was this helpful?