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?
revese
the list instead of sort it ascending? 2) What is the purpose of[start, 'start+size']
? A slice of the list from start to (start + size) or a list of length 2 with elements at start and (start + size)? This part is not included in your description (How do you prevent OutOfBoundExceptions?). – Faber