Reputation: 1751
i create the property for a vertex, as
g.addV('sth').property('p1', '1').property('p2', '2').property('p3', '3')
however when I query the vertex, like
g.V().hasLabel('sth').valueMap(true)
or
g.V().hasLabel('sth').properties()
the order of the properties is lost, I get p3, p1, p2, how can I make sure I can order the property like the order I created.
Upvotes: 1
Views: 703
Reputation: 46226
Gremlin does not guarantee order for any result stream so if you need a specific order then you need to sort yourself:
gremlin> g.V().hasLabel('sth').valueMap().order(local).by(keys,desc)
==>[p3:[3],p2:[2],p1:[1]]
Of course, that isn't insertion order and I'm not sure how you would be able to achieve that as Gremlin does not have that information available to it - only the underlying graph database does. You may be beholden to what the underlying graph allows with respect to this.
Upvotes: 1