I am trying to find a query designer for the Neo4j Cypher query language, ideally using a free API. I did not find much and decided to spend some time creating it.
The result is still a smooth API request builder for the Cypher 1.9 specification.
I wanted to use StackOverflow to start the discussion and see what those thoughts were before I let go of the code.
Here is a demo request that you want to send to Neo4j using Cypher.
Show me all the people who know John, who know Googleโs software engineers (Google code counts 12345). The strength of the relationship between John and the people who connect him with Google employees should be at least 3 (with a range of 1 to 5). Bring back all of Johnโs connections with the people they know on Google, including the relationship between these people. Sort the results by John compound names in ascending order, and then by relationship strength in descending order.
Using Fluent-Cypher:
Cypher .on(Node.named("john").with(Index.named("PERSON_NAMES").match(Key.named("name").is("John")))) .on(Node.named("google").with(Id.is(12345))) .match(Connection.named("rel1").andType("KNOWS").between("john").and("middle")) .match(Connection.named("rel2").andType("KNOWS").between("middle").and("googleEmployee")) .match(Connection.withType("WORKS_AT").from("googleEmployee").to("google")) .where(Are.allOfTheseTrue(Column.named("rel1.STRENGTH").isGreaterThanOrEqualTo(3) .and(Column.named("googleEmployee.TITLE").isEqualTo("Software Engineer")))) .returns(Columns.named("rel1", "middle", "rel2", "googleEmployee")) .orderBy(Asc.column("middle.NAME"), Desc.column("rel1.STRENGTH"))
which gives the following query:
START john=node:PERSON_NAMES(name='John'),google=node(12345) MATCH john-[rel1:KNOWS]-middle,middle-[rel2:KNOWS]-googleEmployee,googleEmployee-[:WORKS_AT]->google WHERE ((rel1.STRENGTH >= '3' AND googleEmployee.TITLE = 'Software Engineer')) RETURN rel1,middle,rel2,googleEmployee ORDER BY middle.NAME ASC,rel1.STRENGTH DESC
neo4j cypher dsl fluent query-builder
sebastij
source share