赞
踩
- --创建节点
- CREATE (p:Person { name:"Keanu Reeves", born:1964 })
- --创建节点和关系
- CREATE (p:Person{name:"kay"})-[:KNOWS]->(:Person{name:"Keanu Reeves"}) return p
-
- --查询
- MATCH (p:Person) WHERE p.name="kay" return p
- --或者
- MATCH (p:Person{name:"kay"}) return p
- --查询关系路径
- MATCH path=(p:Person{name:"kay"})-[:KNOWS]->(p:Person) return path
-
- --修改
- MATCH (p:Person) WHERE p.name="kay" set p.name="fen" return p
-
- --删除节点
- MATCH (p:Person) WHERE p.name="kay" delete p
- --删除关系
-
-
- --彻底删除(清空数据库,包括关系)
- MATCH (n) DETACH DELETE n
实用例子
- CREATE (a:Person { name:"Tom Hanks",
- born:1956 })-[r:ACTED_IN { roles: ["Forrest"]}]->(m:Movie { title:"Forrest Gump",released:1994 })
- CREATE (d:Person { name:"Robert Zemeckis", born:1951 })-[:DIRECTED]->(m)
- RETURN a,d,r,m
查询
- --查询
- MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title
-
- --查询 Tom Hanks 演过的所有电影
- MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies
-
-
- --谁导演了 Forrest Gump
- MATCH (movie {title: "Forrest Gump"})<-[:DIRECTED]-(directors) RETURN directors.name
-
- --Tom Hanks' co-actors...
- MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) RETURN coActors.name
- --How people are related to "Forrest Gump"...
- MATCH (people:Person)-[relatedTo]-(:Movie {title: "Forrest Gump"}) RETURN people.name, Type(relatedTo), relatedTo
超详细neo4j安装教程_至少我有我a的博客-CSDN博客_neo4j安装
Neo4j安装及简单使用_vivian_ll的博客-CSDN博客_neo4j
知识图谱-neo4j入门_Voyager-m的博客-CSDN博客_neo4j图谱
基于电影知识图谱的智能问答系统(二) -- Neo4j导入CSV文件_appleyk的博客-CSDN博客_基于neo4j的知识问答系统
【知识图谱实战】 Neo4j入门与示例___盛夏光年__的博客-CSDN博客_neo4j示例
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。