2

Let's say I'm creating a database about food and in it, I want to add Dal which would be both Curry and Lentil.

SELECT * FROM cypher('menu', $$
        CREATE (:LENTIL:CURRY {name:"Dal"})
        $$) AS (dal agtype);
2023-02-20 06:49:01.568 IST [145143] ERROR:  syntax error at or near ":" at character 49
2023-02-20 06:49:01.568 IST [145143] STATEMENT:  SELECT * FROM cypher('menu', $$
        CREATE (:LENTIL:CURRY {name:"Dal"})
        $$) AS (dal agtype);
ERROR:  syntax error at or near ":"
LINE 2:  CREATE (:LENTIL:CURRY {name:"Dal"})

That does not seem to be working.

It does not work with SET clause either: -

SELECT * FROM cypher('menu', $$
MATCH (dal:CURRY {name: "Dal Makhani"})
SET dal:LENTIL
RETURN dal
$$) AS (dal agtype);
2023-02-20 06:29:38.402 IST [145143] ERROR:  syntax error at or near ":" at character 80
2023-02-20 06:29:38.402 IST [145143] STATEMENT:  SELECT * FROM cypher('menu', $$
    MATCH (dal:CURRY {name: "Dal Makhani"})
    SET dal:LENTIL
    RETURN dal
    $$) AS (dal agtype);
ERROR:  syntax error at or near ":"
LINE 3: SET dal:LENTIL

Is there any work-around for this?

Ken White
  • 123,280
  • 14
  • 225
  • 444

11 Answers11

1

It is not possible for now but the work around you can use is treating that label as a property and make it as an array type, and keep the label unified for example a :Person has is working multiple jobs to get more money it will get a property called { jobs:["Teacher", "Football player"] }

1

Creating multi-label vertex is not possible in Apache AGE since it comes up with subtle complexities but the work is in progress for multi-label vertices which might be available in next releases of Apache AGE.

For your case if you want to associate dal with multiple properties like CURRY and LENTIL then you can create vertex with label dal and further its properties as LENTIL and CURRY

Umer Freak
  • 21
  • 3
1

While multi-label vertices might be introduced in future releases of Apache AGE, currently it is not possible to assign multiple labels to node. An alternative approach can be having separate nodes and creating relationships between them.

1

Apache AGE has not came up with the feature creating multiple vertices because it is complicated, but in the next realeases of Apache Age, it might be added.

Aadil Bashir
  • 111
  • 5
0

Adding multiple labels to a vertex is not possible as of now.

Prachi
  • 39
  • 3
0

Creating a node with multiple labels is not possible for now in Apache AGE.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34551896) – user12256545 Jun 22 '23 at 09:01
0

As others have already mentioned creating a node with multiple labels is not supported by Apache AGE as of yet however, there's definitely some work arounds that you can use. Here's my suggestions:

  • You can try assigning properties to the node instead of labels that way you might be able to achieve the same functionality.
  • Another solution could be to have separate nodes and have a relationship between them. DAL can have a label "Food" and Curry and Lentil can have a label "Category" with a BELONGS_TO relationship between them.

Only you can decide what works best for your case as these are just suggestions.

0

Creating multiple labels is not currently supported in apache age, a work around to this is to probably create a property which holds an array of your custom labels for each food you create/add.

Peter
  • 43
  • 4
0

AGE does not support multiple labels right now. You can make dal have an array with lentil and curry as {category: ["lentil","Curry"]}. Then you can create its relation with a vertex of food. Thismight be one work aroud of having multiple labels for a single vertex.

0

As others have already mentioned that its not possible for now. One work around could be creating an array like { genres: ["Action", "Adventure"] }. Its same like in older cpp versions we can't return multiple values from a function. But we can return an array having different values that we want to return.

Zeeshan
  • 71
  • 2
0

It is not possible to create multi-label vertices in Apache AGE at the moment, But you can try assigning properties Like you can assign properties to a node using the SET clause to the node instead of labels that way you might be able to achieve the same functionality