- Retrieve Concept Types and Their Instances
- Get the Variables
- Limit the Answers
- Sort the Answers
- Offset the Answers
- Clients Guide
- Summary
Retrieve Concept Types and Their Instances
The get
query triggers a search in the knowledge graph based on what has been described in the preceding match
clause. To try the following examples with one of the TypeDB clients, follows these Clients Guide.
Get the Variables
Any variable that has been specified in the match
clause can be returned as the answers of the get
query. Let’s look at an example of how variables can be asked for in the answer.
If the get
clause is omitted, all variables specified in the match
clause are returned.
Limit the Answers
We can chose to limit the number of answers in the results. To do this, we use the limit
keyword followed by the desired number of answers.
This query returns only one single (and random) instance of type person
.
Sort the Answers
To sort the answers by a particular variable, we use the sort
keyword followed by the variable by which we would like the results to be sorted. A second argument, asc
(ascending) or desc
(descending), determines the sorting method.
This query returns all instances of the person
(entity) type sorted by their full-name
.
Offset the Answers
Often used in conjunction with limit
, we use the offset
keyword followed by the number we would like the answers to be offset by. This is commonly used to return a desired range of the answers.
This returns 10 instances of the person
(entity) type starting from the 6th person sorted by their full-name
. If no sorting method argument is provided (i.e. asc
or desc
), we sort in ascending order.
Clients Guide
Summary
A get
query is used to extract information out of the knowledge graph by describing the desired result in the preceding match
clause. We use the modifiers limit
, sort
and offset
to retrieve an optionally sorted subset of the matched instances.
Next, we learn how to insert data into a TypeDB knowledge graph.