Nebula语法-nGQL

nGQL语法大致兼容Cypher语法

1、创建表空间
CREATE SPACE CODING_ENGINE (vid_type = FIXED_STRING(32)) ;


2、创建顶点vertice
CREATE TAG TAGNAME
(
create_time datetime NULL,
description string NULL,
display_order int NULL,
update_time datetime NULL
);


3、创建边edge
CREATE EDGE EDGENAME
(create_time datetime NULL,
update_time datetime NULL
);


4、创建索引
CREATE TAG INDEX I_TAGNAME_INDEX on TAGNAME();
CREATE EDGE INDEX I_EDGENAME_INDEX on EDGENAME();


5、查询
#返回顶点数据
MATCH ( d:TAGNAME ) RETURN d
#返回顶点数量
MATCH ( d:TAGNAME ) RETURN count(d);
#精确匹配字段值
MATCH ( d:TAGNAME {description : 'field_vlue'} ) RETURN d
MATCH ( d:TAGNAME {description : 'field_vlue'} )-[r:EDGENAME*1..5]->(l:TAGNAME) RETURN l;


MATCH (l:TAGNAME)-[r:EDGENAME*1..5]-> (d:TAGNAME {real_estate_unit_num :'360121002002GB00005WGY000001'}) RETURN l;


MATCH (v:TAGNAME{real_estate_unit_num:'360121002002GB00005W00000000'})<- [r:EDGENAME] -> (v2) where r.is_hard == '0' RETURN id(v2) as VertexID,v2.land_use_stage as land_use_stage,v2.real_estate_unit_num as real_estate_unit_num;


MATCH (v:TAGNAME{real_estate_unit_num:'360121002002GB00005WGY000002'})<- [r:EDGENAME] -> (v2) where r.is_hard == '0' and v2.land_use_stage == 'TDDJ' and v2.real_estate_unit_num is not null RETURN id(v2) as VertexID,v2.land_use_stage as land_use_stage,v2.real_estate_unit_num as real_estate_unit_num;

"MATCH (v:TAGNAME{real_estate_unit_num:'" + bdcdyh + "'}) <- [r:EDGENAME] -> (v2) where r.is_hard == '1' RETURN id(v2) as VertexID,v2.real_estate_unit_num AS real_estate_unit_num,v2.land_use_stage as land_use_stage;";


插入顶点语句
insert vertex TAGNAME (create_time,land_use_stage,real_estate_unit_num) VALUES "00579b94e8c447019708312b3010747U":(datetime("2022-06-28T17:51:40.000000"),"TDGY","360122020010GB00195WGY000001")

查看顶点属性结构语句
DESC TAG TAGNAME

查看顶点属性语句
FETCH PROP ON TAGNAME "20579b94e8c447019708312b3010747U" YIELD PROPERTIES(VERTEX)

更新顶点语句
UPDATE VERTEX ON TAGNAME "20579b94e8c447019708312b3010747U" SET real_estate_unit_num='362122020010GB00195W00000001'

删除顶点语句
DELETE VERTEX "20579b94e8c447019708312b3010747U"
#DELETE VERTEX "20579b94e8c447019708312b3010747U" WITH EDGE-----好像不支持WITH EDGE 格式,提示语法错误

插入边语句
INSERT EDGE EDGENAME (create_time,is_hard,update_time) VALUES
"10579b94e8c447019708312b3010747U"->"20579b94e8c447019708312b3010747U" : (datetime("2022-07-16T11:33:16.000000"),"0",datetime("2022-07-20T11:33:16.000000"))

更新边属性语句 两个id为顶点的id,0表示边的序号
UPDATE EDGE ON EDGENAME "c32635d8d43f42379c3a941e309039c8"->"8ed5397b44f14d838a0324760a26465e"@0 SET is_hard='1'

UPDATE EDGE ON EDGENAME "10579b94e8c447019708312b3010747U"->"20579b94e8c447019708312b3010747U"@0 SET update_time=null

删除边语句
delete EDGE EDGENAME "10579b94e8c447019708312b3010747U" ->"20579b94e8c447019708312b3010747U"@0

统计点、边总量
#收集统计信息,如果有数据更改的话需要先执行这个语句,否则统计数量不一定正确
SUBMIT JOB STATS;
#显示点、边统计数量
SHOW STATS;

posted @ 2022-09-20 18:33  publiter  阅读(167)  评论(0编辑  收藏  举报