![](/img/trans.png)
[英]Need help and Want to know how we can write this type of Neo4j Cypher query into Gremlin query?
[英]How to implement Gremlin query corresponding to Neo4j cypher 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 *
請幫助,謝謝:)
如果我理解正確,那么您正在嘗試運行 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.