NASA666

不以物喜,不以己悲.
Posted on , viewed 546 times

neo4j基本查询

基本操作

  1. 删除所有节点和关系(clear db):
    MATCH (n), ()-[r]-() DELETE n,r
  2. 删除所有关系:
    MATCH ()-[r]-() DELETE r
  3. 删除所有节点:
    MATCH (n) DELETE n
  4. 查询某一个或几个节点:
    MATCH (n:Currency) WHERE n.uuid = “USD” or n.uuid = “CNY” RETURN n
  5. 查询和某一节点有关系的所有节点:
    MATCH (c:Currency {uuid: ‘USD’})-[r]-(n) RETURN r, n, c
  6. 查询最短路径及路径上所有节点:
    MATCH p=shortestPath((p1:Currency {uuid: “ETH”})-[:CONVERT*..4]->(p2:Currency {uuid: “CNY”})) RETURN REDUCE(f=1, c in relationships(p) | f * c.price ) as r, p