Last active
October 16, 2015 14:24
-
-
Save dnauck/ac9b1e7a991a0868a92d to your computer and use it in GitHub Desktop.
Neo4j Graph Gist example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Neo4j Graph Gist Example | |
Some application to server relation test from http://stackoverflow.com/q/28805075/1522061 | |
=== Setup | |
//setup | |
[source,cypher] | |
---- | |
CREATE | |
(:Application {Name: "Test Application", Aliases: ["Test", "App", "TestProject"]}), | |
(:Application {Name: "Another Application", Aliases: ["A-App", "XYZ", "XYProject"]}), | |
(:Application {Name: "Database X", Aliases: ["DB-App", "DB", "DB-Project"]}), | |
(:System {Name: "Server1", Application: "TestProject"}), | |
(:System {Name: "Server2", Application: "Test Application"}), | |
(:System {Name: "Server3", Application: "another App"}), | |
(:System {Name: "Server4", Application: "Some Database"}), | |
(:System {Name: "Server5", Application: "App"}), | |
(:System {Name: "Server6", Application: "App XY"}), | |
(:System {Name: "Server7", Application: "App DB"}), | |
(:System {Name: "Server8", Application: "Test"}), | |
(:System {Name: "Server9", Application: "TestProject"}), | |
(:System {Name: "Server10", Application: "test"}), | |
(:System {Name: "Server11", Application: "App XY"}); | |
CREATE INDEX ON :Application(Name); | |
CREATE INDEX ON :Application(Aliases); | |
CREATE INDEX ON :System(Application); | |
MATCH (a:Application { Name: "Test Application"}) | |
WITH a | |
MATCH (s:System) | |
WHERE s.Application IN (a.Aliases + a.Name) | |
AND NOT (a)-[:InstalledOn]->(s) | |
CREATE UNIQUE (a)-[:InstalledOn]->(s) | |
---- | |
//graph |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment