pkb contents > neo4j | just under 281 words | updated 06/08/2017

1. Neo4j

The editor accepts input:

The stream displays output:

2. Cypher

2.1. Create

2.1.1. Nodes

This makes a node named "ee" with label "Person" and attributes "name", "from", and "klout":

CREATE (ee:Person { name: "Emil", from: "Sweden", klout: 99 })

This makes two nodes with different names, the same label ("Person"), and differing attributes:

CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }),
(ir:Person { name: "Ian", from: "England", title: "author" })

2.1.2. Relationships (edges)

CREATE (node_name)-[:RELATIONSHIP_NAME {relationship_attribute: value}] -> (node_name)

CREATE (ee)-[:KNOWS {since: 2001}]->(js), (ee)-[:KNOWS {rating: 5}]->(ir)

2.2. Retrieve

Find a nodel labeled "Person" and named "Emil":

MATCH (ee:Person) WHERE ee.name = "Emil" RETURN ee;

Find all Emil's friends by:

MATCH (ee:Person)-[:KNOWS]-(friends) WHERE ee.name = "Emil" RETURN ee, friends

2.2.1. Recommend

Recommend a similar friend of friend by:

MATCH (js:Person)-[:KNOWS]-()-[:KNOWS]-(surfer)
WHERE js.name = "Johan" AND surfer.hobby = "surfing"
RETURN DISTINCT surfer

2.2.2. Analyze queries

PROFILE MATCH ...
EXPLAIN MATCH ...

2.3. Delete

Delete everything:

MATCH (n)
DETACH DELETE n