如何在 Gremlin PipeLine 中根据方向查询到第 n 级
How to query up to nth level based on direction in Gremlin PipeLine
我想知道如何根据 Gremlin PipeLine 中的方向将 child 节点提升到 n
级别。我想编写一个通用查询,用于查询到第 n
级。
例如,假设我有一个顶点A。它的直接children是[B,C,D](级别1)。第二级的 children 是 [E,F,G]。我想编写一个查询,在任何特定级别(即 1 或 2)[=12] 给出 children =]
使用循环:http://gremlindocs.com/#branch/loop。可以限制循环次数。
List<Vertex> vertexList = new GremlinPipeline(graph).V().has("mgrNo", 312552919).out("manager of").loop(1, new PipeFunction<LoopBundle,Boolean>() {
@Override
public Boolean compute(LoopBundle bundle) {
//System.out.println("in loop bundle");
return bundle.getLoops() < n;
}
}).toList();
其中 n
是您要查询的级别。
我想知道如何根据 Gremlin PipeLine 中的方向将 child 节点提升到 n
级别。我想编写一个通用查询,用于查询到第 n
级。
例如,假设我有一个顶点A。它的直接children是[B,C,D](级别1)。第二级的 children 是 [E,F,G]。我想编写一个查询,在任何特定级别(即 1 或 2)[=12] 给出 children =]
使用循环:http://gremlindocs.com/#branch/loop。可以限制循环次数。
List<Vertex> vertexList = new GremlinPipeline(graph).V().has("mgrNo", 312552919).out("manager of").loop(1, new PipeFunction<LoopBundle,Boolean>() {
@Override
public Boolean compute(LoopBundle bundle) {
//System.out.println("in loop bundle");
return bundle.getLoops() < n;
}
}).toList();
其中 n
是您要查询的级别。