创建

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

创建更多

  1. MATCH (ee:Person) WHERE ee.name = "Emil"
  2. CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }),
  3. (ir:Person { name: "Ian", from: "England", title: "author" }),
  4. (rvb:Person { name: "Rik", from: "Belgium", pet: "Orval" }),
  5. (ally:Person { name: "Allison", from: "California", hobby: "surfing" }),
  6. (ee)-[:KNOWS {since: 2001}]->(js),
  7. (ee)-[:KNOWS {rating: 5}]->(ir),
  8. (js)-[:KNOWS]->(ir),
  9. (js)-[:KNOWS]->(rvb),
  10. (ir)-[:KNOWS]->(js),
  11. (ir)-[:KNOWS]->(ally),
  12. (rvb)-[:KNOWS]->(ally)

查询

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

查询Emil的朋友们

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

推荐-查找关联关联

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

分析

EXPALAIN 或者 PROFILE

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