Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Neo4j Graph Gist example
== Neo4j Graph Gist Example
Some application to server relation test from
=== Setup
(: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"})
MATCH (s:System)
WHERE s.Application IN (a.Aliases + a.Name)
AND NOT (a)-[:InstalledOn]->(s)
CREATE UNIQUE (a)-[:InstalledOn]->(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment