saws
saws

Reputation: 103

gremlin query to add list of values as edge property

I am trying to find a way to add list of values as a property of an edge on the graph. I was able to do it on a vertex with the following query but it doesn't work for an edge.

e.g

gremlin> g.V(2).property(list, 'test', 'a')
==>v[2]
gremlin> g.V(2).property(list, 'test', 'b')
==>v[2]
gremlin> g.V(2).values('test')
==>a
==>b
gremlin> 

If i do the similar thing on an edge i see the following error. Edge property being an list is not supported for edge or what?

gremlin> g.E(2).property(list, 'test', 'a')
org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jEdge cannot be cast 
to org.apache.tinkerpop.gremlin.structure.Vertex
Type ':help' or ':h' for help.

My requirement is to add/remove a value (string) from the list (property of an edge)

I am using neo4j as my database.

Upvotes: 3

Views: 1787

Answers (1)

stephen mallette
stephen mallette

Reputation: 46206

Edges do not support Cardinality. That is a structural feature allowed to vertices only. I believe that you can however store an array of primitives in Neo4j so you could write your "list" that way.

Upvotes: 3

Related Questions