[英]How to implement Gremlin query corresponding to Neo4j cypher query?
I have the following Cypher query(neo4j) and want to convert it to a Gremlin query.我有以下 Cypher 查询(neo4j)并想将其转换为 Gremlin 查询。
MATCH d=(a:Actor {id:" + entityId +'})-[r:ACTING_IN*0..2]-(m) WITH d,
RELATIONSHIPS(d) AS rels WHERE NONE (rel in r WHERE rel.Type = "Hollywood") RETURN *
UNION
MATCH d=(aa:Actor{id: " + entityId + "})-[rel:PRODUCER_OF*0..2]->(mm:Movie) WITH d,
RELATIONSHIPS(d) AS rels return *
Please help, Thanks:)请帮助,谢谢:)
If I understand correctly, then you are trying to run 2 variable length patterns to get path and relationship traversed in those paths.如果我理解正确,那么您正在尝试运行 2 个可变长度模式来获取在这些路径中遍历的路径和关系。 I think below query should do the trick:
我认为下面的查询应该可以解决问题:
g.V(" + entityId +").
hasLabel("Actor").
union(
repeat(outE("ACTING_IN").hasNot('Type', "Hollywood").as('a').inV()).
emit().
times(2),
repeat(outE("PRODUCER_OF").as('a').inV().hasLabel("Movie")).
emit().
times(2)).
path().
project("path", "relationship").by().by(select('a'), all)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.