1 Star 0 Fork 0

极客时间/rag-project04-knowledgegraph

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build_monkey.cypher 4.11 KB
一键复制 编辑 原始数据 按行查看 历史
JiaHuang_c8a5 提交于 3个月前 . 祝大家学习愉快
// 删除已存在的约束
DROP CONSTRAINT constraint_153ebae IF EXISTS;
DROP CONSTRAINT character_id IF EXISTS;
DROP CONSTRAINT weapon_id IF EXISTS;
DROP CONSTRAINT skill_id IF EXISTS;
DROP CONSTRAINT location_id IF EXISTS;
// 创建索引
CREATE CONSTRAINT character_id IF NOT EXISTS FOR (c:Character) REQUIRE c.id IS UNIQUE;
CREATE CONSTRAINT weapon_id IF NOT EXISTS FOR (w:Weapon) REQUIRE w.id IS UNIQUE;
CREATE CONSTRAINT skill_id IF NOT EXISTS FOR (s:Skill) REQUIRE s.id IS UNIQUE;
CREATE CONSTRAINT location_id IF NOT EXISTS FOR (l:Location) REQUIRE l.id IS UNIQUE;
// 创建角色节点
RETURN 'Creating Character nodes';
LOAD CSV with headers from "file:///Sample-CSV/character_new.csv" as line
CALL {
with line
//CREATE (n:Character
MERGE (n:Character
{ nodetype: 'character',
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
FSN: line.FSN,
history: line.history} )
} IN TRANSACTIONS OF 200 ROWS;
// 创建武器节点
RETURN 'Creating Weapon nodes';
LOAD CSV with headers from "file:///Sample-CSV/weapon_new.csv" as line
CALL {
with line
//CREATE (n:Weapon
MERGE (n:Weapon
{ nodetype: 'weapon',
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
FSN: line.FSN,
history: line.history} )
} IN TRANSACTIONS OF 200 ROWS;
// 创建技能节点
RETURN 'Creating Skill nodes';
LOAD CSV with headers from "file:///Sample-CSV/skill_new.csv" as line
CALL {
with line
//CREATE (n:Skill
MERGE (n:Skill
{ nodetype: 'skill',
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
FSN: line.FSN,
history: line.history} )
} IN TRANSACTIONS OF 200 ROWS;
// 创建地点节点
RETURN 'Creating Location nodes';
LOAD CSV with headers from "file:///Sample-CSV/location_new.csv" as line
CALL {
with line
//CREATE (n:Location
MERGE (n:Location
{ nodetype: 'location',
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
FSN: line.FSN,
history: line.history} )
} IN TRANSACTIONS OF 200 ROWS;
// 创建HAS_WEAPON关系
RETURN 'Creating HAS_WEAPON relationships';
LOAD CSV with headers from "file:///Sample-CSV/DR_has_weapon_new.csv" as line
CALL {
with line
MATCH (c:Character { id: line.sourceId }), (w:Weapon { id: line.destinationId })
MERGE (c)-[:HAS_WEAPON {
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
characteristicTypeId: line.characteristicTypeId,
modifierId: line.modifierId,
history: line.history,
rolegroup: line.rolegroup
}]->(w)
} IN TRANSACTIONS OF 200 ROWS;
// 创建HAS_SKILL关系
RETURN 'Creating HAS_SKILL relationships';
LOAD CSV with headers from "file:///Sample-CSV/DR_has_skill_new.csv" as line
CALL {
with line
MATCH (c:Character { id: line.sourceId }), (s:Skill { id: line.destinationId })
MERGE (c)-[:HAS_SKILL {
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
characteristicTypeId: line.characteristicTypeId,
modifierId: line.modifierId,
history: line.history,
rolegroup: line.rolegroup
}]->(s)
} IN TRANSACTIONS OF 200 ROWS;
// 创建LOCATED_IN关系
RETURN 'Creating LOCATED_IN relationships';
LOAD CSV with headers from "file:///Sample-CSV/DR_located_in_new.csv" as line
CALL {
with line
MATCH (c:Character { id: line.sourceId }), (l:Location { id: line.destinationId })
MERGE (c)-[:LOCATED_IN {
id: line.id,
active: line.active,
effectiveTime: line.effectiveTime,
moduleId: line.moduleId,
characteristicTypeId: line.characteristicTypeId,
modifierId: line.modifierId,
history: line.history,
rolegroup: line.rolegroup
}]->(l)
} IN TRANSACTIONS OF 200 ROWS;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/geektime-geekbang_admin/rag-project04-knowledgegraph.git
git@gitee.com:geektime-geekbang_admin/rag-project04-knowledgegraph.git
geektime-geekbang_admin
rag-project04-knowledgegraph
rag-project04-knowledgegraph
master

搜索帮助