Для более поздних тренировок с проектом CAPS мне нужно хранить 2 разных графика в одном:
Graph3=Graph1+Graph2
Я пытался найти решения длясделать это, и я нашел UNION ALL
, но последний не работает, как я ожидал.Есть ли другой способ сделать это с Cypher?
Пример:
val Graph1=session.cypher("""
| FROM GRAPH mergeGraph
| MATCH (from)-[via]->(to)
|WHERE substring(from.geohash,0,5)=substring(to.geohash,0,5)
| CONSTRUCT
| CREATE (h1:HashNode{geohash:substring(from.geohash,0,5)})-[COPY OF via]->(h1)
| RETURN GRAPH
""".stripMargin).graph
, который содержит этот шаблон:

val Graph2=session.cypher("""
| FROM GRAPH mergeGraph
| MATCH (from)-[via]->(to)
|WHERE substring(from.geohash,0,5)<>substring(to.geohash,0,5)
| CONSTRUCT
| CREATE (:HashNode{geohash:substring(from.geohash,0,5)})-[COPY OF via]->(:HashNode{geohash:substring(to.geohash,0,5)})
| RETURN GRAPH
""".stripMargin).graph
, который содержит этот шаблон:

С объединением All:
Graph3=Graph1.unionAll(Graph2)
Я получаю этот график:

Как видите, зеленые узлы - это узлы Graph2 без отношения!это то, чего я не ожидал.