Python – Get the start and end node IDs of the edges, no map step() gremline for neptune

Get the start and end node IDs of the edges, no map step() gremline for neptune… here is a solution to the problem.

Get the start and end node IDs of the edges, no map step() gremline for neptune

I’m working on Neptune AWS and trying to determine the start node ID and end node ID for the edge. The mapping steps work for Neo4j, but the same query doesn’t work for Neptune.

Data example: Enter link description here

Query:

   query = """g.V().hasLabel('Person').has("name", "marko").as("from", "to")
        .repeat(bothE().as("e").otherV().as("to").as("to")).times(2).emit(hasLabel("Person")).hasLabel("Person").has("name", "josh")
        .project("name",  "Label","start", "end")
        .by(select(all, "to").unfold().values("title").fold())
        .by(select(all, "to").unfold().label().fold())
        .by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.outV().id().fold())
        .by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.inV().id().fold())
    """

This goes wrong in Neptune, but it works on Neo4j. Is there any other way to get the start and end node IDs.

Solution

I’m not sure I understand why you need to do this :

.by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.outV().id().fold())

This is not reduced to:

.by(select(all, "e").unfold().outV().id().fold())

This will get rid of lambda, which I think is your problem with Neptune.

Related Problems and Solutions