Officially out now: The TypeDB 3.0 Roadmap

is

The is keyword statement is used in TypeQL patterns to specify equality between two concept variables.

Syntax

The syntax of an is statement includes:

  • Subject — a concept variable

  • Predicate — the is keyword

  • Object — another concept variable

Syntax
<concept-variable> is <concept-variable>;

Behavior

TypeQL statements with the is keyword are used in data queries to set an equality constraint for any two concept variables. That makes two concept variables equal both by type and value, so we could replace one of the variables with another.

Usage for equality

For this example, use a database with the IAM schema and sample data loaded.

Let’s match different concept variables that are set to be equal and fetch values of the same attribute type:

Example
match
$p1 has full-name $f1;
$p2 has full-name $f2;
$p1 is $p2;
fetch $f1 as first; $f2 as second;
Output example
{
    "first": { "value": "Kevin Morrison", "type": { "label": "full-name", "root": "attribute", "value_type": "string" } },
    "second": { "value": "Kevin Morrison", "type": { "label": "full-name", "root": "attribute", "value_type": "string" } }
}

It can be used for simplifying patterns or combining two different patterns into a single one.

Usage with negation

For this example, use a database with the IAM schema and sample data loaded.

The most common use of an is statement is to exclude some results.

For example, let’s find all users that have similar emails. To do that, match two data instances of the user type, both having the same email attribute. But to exclude the results where the same entity matches both concept variables, add a negated is statement with these variables.

Negation example
match
$u1 isa user, has email $e;
$u2 isa user, has email $e;
not {$u1 is $u2;};
fetch
$e;

In our IAM database sample dataset that query returns no results.

Learn more

Learn more about isa statement in TypeQL.

Learn about data instances in TypeQL.