I have a simple graph, with parents and children being vertices. Parents have the relationship "isParentOf" to their children. The vertices all have one property: the "familyName".
I want to use gremlin to match all the parents whose child's familyName is different from theirs.
Note: I cannot use the Groovy syntax of Gremlin. I must use pure Java code only.
The GremlinPipeline should look like this:
The problem is in the last step. How to retrieve the parent's "familyName", when this pipeline step only has access to (what is coming from the previous step, that is to say) the children?
My answer:
Accessing previous steps of a GremlinPipeline in a filter's PipeFunction is not possible. BUT it is possible if you use a PipesFunction instead (note the 's' !).
Let's look at the javadoc here:
So you should setup the GremlinPipeline like this:
filter the children with a PipesFunction like this:
Note: in the step 4, we could retrieve the "theParent" vertex thanks to the getAsMap() method, and thanks to the step 2 (that implicitly filled the "As" map).