Nubula关系图谱笔记

#关系图谱操作

查看图空间

SHOW SPACES;

添加连接storage

— 操作图数据库前需add hosts —
add hosts 127.0.0.1:9779 #注意:登录时连接9669服务,控制台操作add的是9779服务

创建图空间

CREATE SPACE IF NOT EXISTS anti(partition_num=100,replica_factor=1,vid_type=FIXED_STRING(100));

创建标签(定义点)

CREATE TAG people(id string,foreign_id string,name string,type int DEFAULT 1,phone string,idnum string,face_path string);

查看空间的索引

SHOW TAG INDEXES;

创建索引 变长的属性的索引需要指定索引长度

CREATE TAG INDEX people_id_index ON people(id(20));

创建索引后需要REBUILD

REBUILD TAG INDEX people_id_index

创建边类型

CREATE EDGE IF NOT EXISTS unit(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS address(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS hotel(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS rental_house(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS phone(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS no_phone(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS inflow(start_date string,end_date string,content string);
CREATE EDGE IF NOT EXISTS outflow(start_date string,end_date string,content string);

反向查找关系

match p=(v:people{id: ‘26’})<-[:phone]-(v2) return v2

删除边类型

drop edge unit;

插入边数据

INSERT EDGE unit (start_date, end_date, content) VALUES “11”->“13”@日期20220905:(“2022-08-24”, “2022-08-24”,“xx单位”);

查边的rank值

GO FROM “615121615334916096” OVER phone
WHERE phone._dst == “615123044875354112”
YIELD phone._rank AS rank

删除两点的同类型的所有边

GO FROM “615121615334916096” OVER phone
WHERE phone._dst == “615123044875354112”
YIELD phone._src AS src, phone._dst AS dst, phone._rank AS rank | DELETE EDGE phone − . s r c − > -.src-> .src>-.dst @ $-.rank;

列出所有顶点

MATCH (n:people) RETURN id(n)

删除多个顶点

DELETE VERTEX “player100”, “player101”;

根据边类型及边值返回所有顶点(并去重)

MATCH (v:people)-[e:phone]-(v2) where rank(e)<= 2 and rank(e)>=1 WITH DISTINCT v2 as v2 RETURN v2 ;

某点出发一步内的边的数据

go 1 steps from “615121615334916096” over phone yield dst(edge) as target,src(edge) as source, properties(edge) as props

某点关联(出度&入度)的所有类型的无向边

MATCH (v:people{id:“32”})-[e]-(v2) WITH DISTINCT v2 RETURN v2 ;

变长搜索边

MATCH p=(v:people{id:“31”})-[e:phone0…3]-(v2) RETURN DISTINCT v2 AS phone SKIP 3 limit 2;

MATCH p=(v:people)-[e:phone
0…3]-(v2) where id(v) == “615121615334916096” RETURN DISTINCT v2 AS phone SKIP 3 limit 2;

go查双向边

go from “615121615334916096” over phone BIDIRECT yield phone.start_date,phone.end_date,type(edge),id( ) , i d ( ^), id( ),id($),src(edge),dst(edge) ;

统计分析

SUBMIT JOB STATS;//提交分析任务
SHOW JOB 31;//查看任务是否执行完
SHOW STATS;//展示统计数据

边建立查询索引

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值