Search code examples
gremlinamazon-neptune

Gremlin/Neptune: sort edges by vertex property


Using the gremlin console connected remotely to a Neptune DB instance, I am grabbing all edges with a specific label and want to sort them by the id of the out vertex. I'm getting this error: "code":"UnsupportedOperationException","detailedMessage":"com.amazon.neptune.storage.volcano.ast.CutoffNode cannot be cast to com.amazon.neptune.storage.volcano.ast.AbstractGroupNode".

Sample data:

g.addV('user').property(id,'1').
  addV('content').property(id,'2').
  addE('history').property('val',9).from(g.V('1')).to(g.V('2'))

Queries and outputs:

g.E().hasLabel('history').order().by('val')
==>e[3][1-history>2]
g.E().hasLabel('history').outV().id()
==>1
g.E().hasLabel('history').order().by(outV().id())
{"requestId":<stuff>,"code":"UnsupportedOperationException","detailedMessage":
"com.amazon.neptune.storage.volcano.ast.CutoffNode cannot be cast to 
com.amazon.neptune.storage.volcano.ast.AbstractGroupNode"}

I expect the result of that last one to be the same as the first. I've tried the same traversal in a TinkerGraph and didn't get an error, so judging by that and the message it's specifically a Neptune problem. Googling hasn't brought up anything.

Is there a traversal that will do what I'm looking for? What am I doing wrong?


Solution

  • I will look into why the error is being thrown but in the near term I think this workaround should work. Please let me know if it does not.

    g.E().order().by(identity().outV().id())

    Cheers, Kelvin