【问题标题】:Translating a Neo4j cypher query into orientdb / gremlin (in java)将 Neo4j 密码查询转换为 orientdb / gremlin(在 java 中)
【发布时间】:2015-12-30 16:15:12
【问题描述】:

我有一个如下所示的 Neo4j 密码查询:

匹配 (b:VertexType1)-[e1]-(a:VertexType2)-[e2]-(c:VertexType1)-[e3]-(d)

这翻译成英文(我认为)是:

“按顺序为我查找类型为 'VertexType1'、'VertexType2'、'VertexType1' 和 'VertexTypeAny' 的顶点链 'b'、'a'、'c'、'd' em> 由 任何类型的 边 'e1'、'e2' 和 'e3' 连接"

在 java 中使用 OrientDB 和 gremlin 的等价物是什么?

如果我想从以下开始:

for(Vertex a : orientGraph.getVerticesOfClass("VertexType2")){

}

然后从顶点'a'开始我的gremlin代码,然后是'both',以便我从顶点'a'展开,直到我确认/否认a以我想要的方式连接。

最后我想在 Java 中拥有所有的顶点和边,这样我就可以添加/删除边和顶点,所以我有:

OrientVertex a;
OrientVertex b;
OrientVertex c;
OrientVertex d;
OrientEdge e1;
OrientEdge e2;
OrientEdge e3;

java 中的 gremlin 可以做到这一点吗?

【问题讨论】:

    标签: java neo4j orientdb gremlin


    【解决方案1】:

    这是您要查找的 gremlin 查询:

     g.V().has('@class', T.eq, 'VertexType1').as('b').bothE().as('e1').bothV().as('a').has('@class', T.eq, 'VertexType2').bothE().as('e2').bothV().as('c').has('@class', T.eq, 'VertexType1').bothE().as('e3').bothV().path
    

    【讨论】:

    猜你喜欢
    • 2021-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多