簡體   English   中英

Neo4j cypher查詢對應的Gremlin查詢如何實現?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM