Aggregating vertices with set-cardinality properties

I am aggregating traversed vertices that have both single and set-cardinality properties. When capturing the vertex using elementMap() it assumes a single-cardinality for all properties and only considers the last element in the set when building the map.
However, when trying to use valueMap(true).by(unfold()) (as described in this SO reply: https://stackoverflow.com/a/75225994/3516889)
It just gives the last property value in the set.

query using valueMap(true).by(unfold()) (1):
g.V()
.hasLabel('SampleContainer')
.filter(properties('samples').count().is(P.gte(2))) // only consider vertices with 2 samples or more
.limit(100)
.valueMap(true).by(unfold())


Query 1 returns only the first-added sample:
{<T.id: 1>: '8ac3ec3b-ffbd-8734-83c0-9f7f7bdbd468', <T.label: 4>: 'SampleContainer', 'name': 'SomeName', 'samples': 'first'}


Query Using elementMap() (2):
g.V()
.hasLabel('SampleContainer')
.filter(properties('samples').count().is(P.gte(2))) // only consider vertices with 2 samples or more
.limit(100)
.elementMap()


Query 2 returns only the last-added sample:
{<T.id: 1>: '8ac3ec3b-ffbd-8734-83c0-9f7f7bdbd468', <T.label: 4>: 'SampleContainer', 'name': 'SomeName',  'samples': 'second'}


What I need is the following result:
{<T.id: 1>: '8ac3ec3b-ffbd-8734-83c0-9f7f7bdbd468', <T.label: 4>: 'SampleContainer', 'name': 'SomeName',  'samples': [ 'first', 'second'] }


I tried playing with local() but I can't seem to get a proper map of the elements with a set-cardinality property.

Appreciate your help!
Stack Overflow
In Tinkerpop3 valueMap is returning an array, how can I get a real key value pair (without Array)?

gremlin> Gremlin.version()
==>3.0.1-incubating

:> def trav = g.V().hasLabel('Group'); t...
Was this page helpful?