Command delete()
will delete existing nodes/edges based on Ultipa filter.
Deleting a node will also delete the edges that start or end with it. Caution should be exercised when deleting data using sophisticated filters since the delete operation is irreversible.
Deletion operation will induce redundant data into the GraphSet and reduce the query efficiency. It is strongly suggested to be cleared on a regular basis, see command
compact()
in GraphSet | Schema | Property.
It is not suggested to execute deletion operation after streaming return of an algorithm, see details on
stream()
in document Ultipa Graph Analytics & Algorithms - Using Algorithms - Execution Method.
Syntax:
- Statement alias: not supported
// To delete N nodes in the current graphset
delete().nodes(<filter>).limit(<N>)
// To delete N edges in the current graphset
delete().edges(<filter>).limit(<N>)
Sample graph: (to be used for the following examples)
Run below UQLs one by one in an empty graphset to create graph data:create().node_schema("account").edge_schema("follow")
create().node_property(@account, "name").edge_property(@follow, "time", datetime)
insert().into(@account).nodes([{_id:"U001", _uuid:1, name:"Jason"}, {_id:"U002", _uuid:2, name:"Tim"}, {_id:"U003", _uuid:3, name:"Grace"}, {_id:"U004", _uuid:4, name:"Ted"}])
insert().into(@follow).edges([{_uuid:1, _from_uuid:4, _to_uuid:1, time:"2021-09-10"}, {_uuid:2, _from_uuid:3, _to_uuid:2, time:"2020-03-12"}, {_uuid:3, _from_uuid:4, _to_uuid:2, time:"2023-07-30"}])
Example: Delete node whose name is Jason
delete().nodes({name == "Jason"})
1 Node(s) Affected
2 Edge(s) Affected
Example: Delete any two edges
delete().edges().limit(2)
2 Edge(s) Affected