I am using Grakn. I'd like to delete a duplicate entity with the same attribute value (name). This is what I have now:
test> match $p isa person, has name $n; get;
{$p id V4176 isa person; $n "John" isa name;}
{$p id V40968336 isa person; $n "John" isa name;}
I would like to delete the one with id V4176. However if I do the query below, it deletes both entities:
match $p isa person, has name "John"; delete $p;
How do I just delete one of the two?
Grakn assigns an auto-generated id
to each instance. Although this id
is generated by Grakn solely for internal use, it is indeed possible to find an instance with its Grakn id
. To do so, we use the id
keyword followed by the id
assigned to the instance by Grakn.
match $p id V4176; delete $p;
Now, the reason your query
match $p isa person, has name "John"; delete $p;
deletes both entities is because both of them are person
and has name John
, so they both match you match
clause.
You can find more information here https://dev.grakn.ai/docs/query/match-clause#one-particular-instance