A delete query will delete the specified variable patterns for every result of the match query. If a variable pattern indicates just a variable, then the whole concept will be deleted. If it is more specific (such as indicating the
isa) it will only delete the specified properties.
To follow along, or experiment further, with the examples given below, please load the basic-genealogy.gql file, which can be found in the examples directory of the Grakn installation zip, or on Github.
match $x isa person; delete $x;
A variable pattern in a delete query describes properties to delete on a particular concept. The variable pattern is always bound to a variable name.
If a variable pattern has no properties, then the concept itself is deleted. Otherwise, only the specified properties are deleted.
Removes the given role from the relation.
match $x type-name "marriage"; delete $x has-role spouse1;
Disallows the concept type from playing the given role.
match $x type-name "person"; delete $x plays-role sibling1;
Deletes the resources of the given type on the concept. If a value is given, only delete resources matching that value.
match $x has identifier "Mary Guthrie"; delete $x has middlename $y;
qb.match(var("x").has("identifier", "Mary Guthrie")).delete(var("x").has("middlename", var("y")));
Want to leave a comment? Visit the issues on Github for this page (you’ll need a GitHub account). You are also welcome to contribute to our documentation directly via the “Edit me” button at the top of the page.