gremlintinkerpop-frames

Gremlin: can't sort edges and return vertices


I'm trying to write a Gremlin query to traverse a graph using Tinkerpop Frames.

Here is the code I have:

@GremlinGroovy("it"
            + ".outE"
            + ".filter{it.label=='usedwith'}"
            + ".sort{-it.weight}"
            + ".toList()"
            + ".reverse()"
            + "[start, 'start+size']"
            +"._"
            + ".inV")
public Iterable<Ingredient> getMostUsedWith(@GremlinParam("start") int start, 
                                            @GremlinParam("size") int size);

I basically want to get all edges from my current vertex with type 'usedwith', sort them based on weight attribute descendingly and then get a page from the list of vertices that these edges are pointing at.

Sadly this code doesn't work and throws a lot of errors. Can you revise this?


Solution

  • Maybe you could write your query as:

    it.outE('usedwith').order{it.b.weight <=> it.a.weight}.inV[start..(start + size)]