I'm new to all the graph database stuff and I'm having a hard time with some basic queries. I'm using Gremlin with Kotlin to connect to AWS Neptune. I want to get all my vertex properties including the Id.
I have added an vertex with:
g.addV("foo")
.property("name", "Foo 1")
.next()
And to retrieve the properties I have tried:
g.V()
.hasLabel("foo")
.valueMap<String>()
.by(unfold<String>())
.forEach {
// val name = it["name"] -> works great!
// val id = it["id"] -> doesn't exist
}
In this first approach I get a map for each item but this map does not contain the ID.
g.V()
.hasLabel("foo")
.forEach {
// it is an ReferenceVertex that has an ID!
val name = it.property<String>("name") // This returns an EmptyVertexProperty, so I can't read the name
}
I'm using
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.4.4</version>
</dependency>
Bonus question
I couldn't figure out (nor find in the documentation) what the generics on valueMap
and unfold
method do. Kotlin does not allow me to ommit them (as I have seem in some java code...?), but changing them to Int
, for instance, changes nothing in the outcome for these examples... So what is it for? D:
Thanks in advance!