Graql Delete Queries
Edit me

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 id or 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;
qb.match(var("x").isa("person")).delete("x").execute();

Variable Patterns

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.

Properties

has-role

Removes the given role from the relation.

match $x type-name "marriage"; delete $x has-role spouse1;
qb.match(var("x").name("marriage")).delete(var("x").hasRole("spouse1"));

plays-role

Disallows the concept type from playing the given role.

match $x type-name "person"; delete $x plays-role sibling1;
qb.match(var("x").name("person")).delete(var("x").playsRole("sibling1"));

has

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")));

Comments

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.

Tags: graql