1

I am using the following sample query to create a node with a label.

SELECT *
FROM cypher('vg-graph', $$
    CREATE (m:Movie {name: "Movie Name", uid: "12345678", body: "Description"})
    $$) as (n agtype);

Following query should remove label 'Movie' from the node.

SET search_path TO ag_catalog;
SELECT *
FROM cypher('vg-graph', $$
    MATCH (n {uid:"12345678"})
    REMOVE n:Movie
    RETURN n
    $$) as (n agtype);

but produces ERROR: syntax error at or near ":"

How can I achieve the same task in other ways?

Abdul
  • 69
  • 5

16 Answers16

1

At present, you can not remove the label name from a node or edge because the ID of node/edge is given from sequence id initially assigned to the label hence coupling the entity existence to its label.

Thus, such an invalid operation would result in an error.

However, separating entity ID from label ID is in progress. This would allow updating/deleting existing labels and adding multiple labels to entities.

Zainab Saad
  • 728
  • 1
  • 2
  • 8
0

Currently, it is not possible to remove the label name from a node or edge because the entity's ID is associated with the label. Removing the label would invalidate the entity's existence, resulting in an error.

Zeeshan
  • 3
  • 1
0

Removing a label from a node or an edge will return an error in Apache AGE because each node or edge is linked with the label passed upon creation.

Tito
  • 289
  • 8
0

Cypher query doesn'have a built in clause for removing the label name, instead you can rename it using the following query.

MATCH (a:Label1)
SET a:Label2
REMOVE a:Label1

You can get more information from this Github issue link as its already raised there.

0

Label modifications and ability to have multiple labels has not yet been added to Apache AGE. At present AGE assigns vertices their ids based on the labels they're given at the time of creation. And because ids are immutable and are fundamentally tied to the label name, it makes removing the label, or modifying the label, or having multiple labels an unsupported task.

However, there are projects going on to implement the same. You can follow them here https://github.com/apache/age/issues/772

0

Removing a label from a node in AGE is currently not supported. However, efforts are underway to enable this functionality. In the meantime, you can accomplish your task by creating a new node with identical properties but different label.

CREATE (a :Label {val: 13})

CREATE (b)
SET b = properties(a)
DELETE a
RETURN b
                                 res                                  
----------------------------------------------------------------------
 {"id": 281474976710663, "label": "", "properties": {"v": 13}}::vertex
(1 row)
Mohayu Din
  • 433
  • 9
0

at present, deleting a node directly using REMOVE clause is under development. Currently you can use alternative solution using SET clause like in the answers above

0

The error that you see "syntax error at or near ":" ", is because as of now, removing label name from a node is not allowed as the node is linked with the label.

Prachi
  • 39
  • 3
0

Theres a issue on github explaining why you can't remove the label from a node. It isn't added in APACHE AGE yet.

Issue

Marcos Silva
  • 115
  • 5
0

You currently cannot remove a label name from a graph as it is not yet supported by Apache AGE, but you can migrate your nodes to a new label and remove the old one.

To gain more insight you can visit these github issues: Link to issue 1 Link to issue 2

0

Currently, removing a label name from a node in Apache AGE is not supported. However, there are alternative ways to achieve a similar outcome. One option is to migrate the nodes to a new label and then remove the old one.

Here's an example of how you can accomplish this:

SELECT * 
FROM cypher('graphName', $$
    CREATE (newNode:NewLabel)
    SET newNode = properties(oldNode)
    DELETE oldNode
    RETURN newNode
$$) AS (newNode agtype);
Abdul Manan
  • 117
  • 5
0

The error is occurring because you cannot remove the label from the node. This functionality is not implemented yet.

But you can use some alternative ways like

  • You can make a new node with a new label and delete the old one.
  • You can rename the label of node using MATCH and SET commands.
adil shahid
  • 125
  • 4
0

You cannot delete/remove the label name from a node because the node is linked/connected with the label.

for example: 0 -> 1

"->" defines relationship between nodes and associate labels.

0

Removal of a label from a node is not currently supported in Apache AGE.

Instead you can rename the label or create a new node tailored according to your needs.

0

As other have mentioned it is not possible currently since the node is linked to the label upon creation and there is an issue related to it. You can possibly migrate the new nodes to another label and then delete the old nodes.

Hassoo
  • 85
  • 11
0

Since a node's or edge's identification or ID is closely linked to the initial assignment generated from a sequence ID that is associated with the matching label, it is currently not possible to separate the label name from a node or edge. This connection effectively connects an entity's very existence to its assigned label. Any effort to execute such an activity, which would effectively involve detaching the label, would therefore inherently result in the issuance of an error because it conflicts with the system's established structural and referential integrity.

Ongoing efforts are being made to separate the entity ID from the label ID. This forward-thinking update seeks to make it easier to add the ability to label individual entities with numerous labels, as well as to alter or delete existing labels. The goal of this effort is to increase the system's adaptability and flexibility in handling labels and the links they have with entities. It is now in an active state of implementation and improvement.

Raja Rakshak
  • 168
  • 2