Nebula操作语句

作者: AC编程 | 来源:发表于2022-06-13 19:01 被阅读0次

一、常用命令

//查询群成员(查边)
GO FROM 'XX12912391' OVER friendsGroupEdge REVERSELY;

二、全局操作

//执行统计任务后,查询图空间统计信息  
SUBMIT JOB STATS
SHOW STATS

// 统计对应Tag的数量
LOOKUP ON memberTag | YIELD COUNT(*) as member_number;

三、点查询

3.1 点查询(MATCH)

注意:MATCH依赖索引

// 遍历对应Tag的所有点,返回所有列信息, 点上需要建有索引
MATCH (v:memberTag) RETURN v

//分页查询
MATCH (v:memberTag) RETURN v,v.id as id ORDER BY id SKIP 10 LIMIT 10;

// 按条件查询会员(查点)   返回指定列  需要查询列为索引
MATCH (v:memberTag) where v.mobile in ['16675119413'] RETURN v.id;

//返回所有列
MATCH (v:memberTag) where v.mobile in ['16675119413'] RETURN v;

// 按条件查询会员(查点) 返回指定列  需要查询列为索引
MATCH (v:memberTag{mobile:"16675119413"}) RETURN v;

// 按条件查询群(查点)   需要查询列为索引
MATCH (v:friendsGroupTag) where v.groupName in ['就是玩'] RETURN v.groupName;

// tags:返回点的标签  properties:接收点或边并返回其属性
MATCH (a:memberTag) WHERE id(a) == "273"  RETURN tags(a), properties(a);

// 不指定TAG查询点
MATCH (v) WHERE id(v) == '273' RETURN v;


// 按条件查询点,再查询该点的所有边(有方向) --   -->   <--
MATCH p=(v:memberTag{mobile:"16675119413"})-->(v2) RETURN p;

3.2 点查询(FETCH)

注意:不依赖索引

// 按ID查询会员(查点)  返回所有列
FETCH PROP ON memberTag "273";

//指定多个点ID获取多个点的属性值
FETCH PROP ON memberTag "273","3","54";

// 按ID查询会员(查点)  返回指定列
FETCH PROP ON memberTag "273" YIELD memberTag.mobile as mobile,memberTag.nickName as nickName;
3.3 点查询(LOOKUP)

注意:

1、LOOKUP依赖索引

2、LOOKUP可查点也可以查边,但都依赖于索引


// 遍历对应Tag的所有点,只返回ID,点上需要建有索引
LOOKUP ON memberTag;

// 统计对应Tag的数量
LOOKUP ON memberTag | YIELD COUNT(*) AS member_number;


// 按条件查询会员(查点)   返回指定列  需要查询列为索引
LOOKUP ON memberTag WHERE memberTag.mobile == '16675119413';

// 按条件查询会员(查点) 返回指定列
LOOKUP ON memberTag WHERE memberTag.mobile == '16675119413' YIELD memberTag.markId, memberTag.nickName;

四、边查询

4.1 边查询(GO FROM)

注意:不依赖索引

//查询273关注的人 (正向查询)   
GO FROM '273' OVER focusEdge;

//查询关注273的人 (反向查询)   
GO FROM '273' OVER focusEdge REVERSELY;

//查询273关注的人 &  关注273的人 (双向查询)
GO FROM '273' OVER focusEdge BIDIRECT;

//查询群成员(查边)
GO FROM 'XX12535911' OVER friendsGroupEdge REVERSELY;

//查询273的好友(查边)
GO FROM '273' OVER friendsEdge;

// 查询边  返回指定列
GO FROM '273' OVER focusEdge YIELD focusEdge._src as id ,focusEdge._dst as dst,focusEdge._rank as rank,focusEdge._type as type,focusEdge.relation as relation;

// 查询1跳:返回结果273 (数据关系:54关注273,273关注102、300)
GO 1 STEPS FROM "54" OVER focusEdge;

// 查询2跳:返回结果102,300(数据关系:54关注273,273关注102、300)
GO 2 STEPS FROM "54" OVER focusEdge;
4.2 边查询(FETCH)

FETCH PROP ON focusEdge "54" -> "273";


FETCH PROP ON focusEdge "54" -> "273" YIELD focusEdge._src;
4.3 边查询(MATCH)
//返回点(用户)相关的所有边关系(正向)
match (v:memberTag) <-[e]-() RETURN e

//分页查询
match (v:memberTag) <-[e]-(v2) RETURN e,v2.id as memberId ORDER BY memberId SKIP 10 LIMIT 10

//返回点(用户)相关的所有边关系(反向)
match (v:memberTag) -[e]->() RETURN e ;

相关文章

网友评论

    本文标题:Nebula操作语句

    本文链接:https://www.haomeiwen.com/subject/hbaomrtx.html