我有以下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 *
请帮忙,谢谢:(
如果我理解正确,那么您将尝试运行2个可变长度模式,以获得在这些路径中遍历的路径和关系。我认为下面的查询应该起作用:
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)