I would like to concatenate all the values of two related vertices in Gremlin.
Given the following:-
g.addV('Path').as('1').
property(single, 'Source', 12345).
addV('PathState').as('2').
property(single, 'Length', 201).
property(single, 'Tag', 'TestTag').
addE('state').from('1').to('2')
I understand I can write a Projection, using named values, like this:
g.V().hasLabel('Path')
.project("Id", "Label", "Length", "Tag")
.by(id)
.by(label)
.by(out('state').values("Length"))
.by(out('state').values("Tag"))
I'm looking for a more generic solution that I can use where the connected 'State' vertices can have different properties.
Is there a generic way to concatenate all the properties of the connected 'state' vertex to the Path one?
I'm using C# Gremlin.Net to try to build a generic method for retrieving 'Vertex with connected StateVertex', so I have a fallback of using reflection to build up the 'by()' bits of a traversal, but it feels like there should be a simpler way.
I think you can get the sort of information you are looking for by using the
path().by(elementMap())
orpath().by(valueMap())
steps in your query like this:If you're looking to have these values returned in a single
Map
you could achieve this through some more complex manipulation in theby()
modulators like this:However, this seems potentially problematic as I am not sure what you are expecting to do with duplicate values.