I am storing multiple values in a gremlin vertex property. Now i want to return all the values of that property in a query.
g.AddV('test').property('id','1').property(list,'name','name1')
g.V('1').property(list,'name','name2')
g.V('1').property(list,'name','name3')
When i do g.V('1')
i get below response.
{
"id": "1",
"label": "test",
"type": "vertex",
"properties": {
"name": [
{
"id": "de80d819-91ca-4b28-8623-aadf652f0afb",
"value": "name1"
},
{
"id": "45fd395c-265e-448a-bdbd-7af9b1a3ce57",
"value": "name2"
},
{
"id": "23a1ee04-0113-4da1-9703-1e9a4f3033e8",
"value": "name3"
}
]
}
}
Now i want to return only values of name
property and id
. Expected result should be as follows
[{
"id": "1",
"names: : [
"name1",
"name2",
"name3"
]
}]
This should work:
g.V('1').valueMap(true, 'name')
And also this one:
g.V('1').project('id', 'names')
.by(id())
.by(values('name').fold())