Adding a list as property value

72 views
Skip to first unread message

Amit Chandak

unread,
Mar 15, 2018, 4:50:54 PM3/15/18
to Gremlin-users
Hi,
    Is it possible to have the property value to be a list. I am using 3.3.1 Gremlin Server with Neo4j plugin. Looked at this thread, but this is not working for me


gremlin> v = g.V().hasLabel("achandak-org/USERS/Alice")
gremlin> v.setProperty("type",["USERS", "USERS-NEW"])

Has this changed in latest gremlin?


Amit

Robert Dale

unread,
Mar 16, 2018, 8:28:31 AM3/16/18
to Gremlin-users
If we look at Neo4j graph.features() we can see that neo4j doesn't support lists but only arrays. Thus, cast to array[].

gremlin> graph  = Neo4jGraph.open('/tmp/nerfo')
==>neo4jgraph[community single [/tmp/nerfo]]
==>graphtraversalsource[neo4jgraph[community single [/tmp/nerfo]], standard]
gremlin> graph.addVertex(label, "achandak-org/USERS/Alice", "type",["USERS", "USERS-NEW"] as String[] )
==>v[0]
gremlin> graph.tx().commit()
==>null
gremlin> g.V().valueMap(true)
==>[label:achandak-org/USERS/Alice,id:0,type:[[USERS, USERS-NEW]]]

Also, it is preferred to use the traversal API to do it all in one shot.

gremlin> g.V().hasLabel("achandak-org/USERS/Alice").property("type",["USERS", "USERS-NEW"] as String[])
==>v[0]
gremlin> g.tx().commit()
==>null
gremlin> g.V().valueMap(true)
==>[label:achandak-org/USERS/Alice,id:0,type:[[USERS, USERS-NEW]]]

Amit Chandak

unread,
Mar 16, 2018, 9:24:06 AM3/16/18
to Gremlin-users
Awesome, thanks Robert

Stephen Mallette

unread,
Mar 16, 2018, 9:25:17 AM3/16/18
to Gremlin-users
The oldest issue currently in TinkerPop:


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/275500cf-0f3d-4a1d-9e56-f35443c939b2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Amit Chandak

unread,
May 16, 2018, 8:34:43 PM5/16/18
to Gremlin-users
Hi Robert,
              How can i query if the array contains a particular value? For eg

g.addV('amit').property('group', ['Dev', 'Arch'] as String[])
==>v[40]
gremlin> g.V(40).properties('group')
==>vp[group->[Ljava.lang.Strin...]
gremlin> g.V(40).properties('group').hasValue('Dev')
gremlin> g.V(40).properties('group').hasValue('Dev')



On Friday, March 16, 2018 at 5:28:31 AM UTC-7, Robert Dale wrote:

Robert Dale

unread,
May 16, 2018, 10:15:44 PM5/16/18
to gremli...@googlegroups.com
Perhaps not efficient, but can be done:

g.V().where(values('group').unfold().where(is('Dev')))


Robert Dale

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages