修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

搜索
    中文

      准备图集

      本文介绍如何在 Ultipa Manager 中进行图建模、插入及修改图数据,并给出 UI 操作及 UQL 语句的示例。

      图模型

      图模型(Graph Model)是指图集(GraphSet)的 schema 和属性

      图1:在 Ultipa Manager 中展示图集 retail 的图模型

      对于 Ultipa Cloud 的用户,可以通过服务器列表中的 'load sample' 功能让 Ultipa Cloud 向某个服务器中自动创建图集、建模并加载图数据。
      对于 自主部署 Ultipa Manager 的用户,请跟着下面的介绍手动建图。

      如何执行 UQL

      create().graph("retail_test")
      

      上面这句 UQL 可以 “创建一个名为 retail_test 的图”。
      在 Ultipa Manager 中,可以在顶部的 CLI 窗口中编写并运行 UQL 语句(图2),某些 UQL 还可以通过 UI 操作进行组装并运行(图3):

      图2:CLI 窗口中运行创建图集的 UQL 语句
      图3:通过 UI 操作进行图集创建

      注意:创建图集后须在图集列表中点击 Select 切换至该图集,才能保证后续操作均针对该图集而进行(图3)。 切换图集是由 SDK 进行的,并非 UQL 功能。

      建模

      图4:通过 UI 操作进行建模

      图4 展示了一个简单的建模过程,其本质是通过 UI 交互拼接了以下两个用于创建 点schema 和点属性的 UQL:

      // 创建 点schema 'customer'
      create().node_schema("customer")							
      
      // 为 点schema 'customer' 创建属性 'balance',数据类型为 'float'
      create().node_property(@customer, "balance", float)			
      

      以上这些 UQL 的特征:

      • 以命令 create() 为开头
      • 参数 node_schema()node_property() 等通过英文句点 '.' 连在命令后
      • 先创建 schema 再创建其属性
      • 用户只创建 自定义属性,不创建 系统属性(解释见下文)

      请根据 图1 所展示的图模型,创建所有 schema 及其属性。

      关于建模的详细语法请见 UQL 文档中的 图集Schema属性

      元数据

      元数据是对 点和边 的统称,也就是之前所讲的图数据。

      插入点

      图5:通过 UI 操作插入点

      点有两个系统属性,_id_uuid,它们均为点的唯一标识符,只是数据类型不同。

      点击阅读更多关于元数据的 唯一标识符

      下面这些 UQL 语句均向 点schema customer 中插入了点:

      insert().into(@customer).nodes({})						// 插入一个点,自定义属性为 null,'_id' 和 `_uuid` 由系统自动分配
      insert().into(@customer).nodes([{},{}])					// 插入两个点,自定义属性为 null,'_id' 和 `_uuid` 由系统自动分配
      insert().into(@customer).nodes({cust_name: "Jason"})	// 插入一个点,'cust_name' 为 'Jason',其他自定义属性为 null,'_id' 和 `_uuid` 由系统自动分配
      insert().into(@customer).nodes({_id: "CU001"})			// 插入一个点,'_id' 为 'CU001',自定义属性为 null,`_uuid` 由系统自动分配
      insert().into(@customer).nodes({cust_name: "Jason", _id: "CU001"})		// 插入一个点,指定 'cust_name' 和 '_id',其他自定义属性为 null,`_uuid` 由系统自动分配
      ...
      

      这些 UQL 的特征:

      • 以命令 insert() 为开头
      • 在参数 into() 中声明 schema,在 nodes() 中将每个点的属性值组织为对象格式
      • 未提供的自定义属性为 null
      • 未提供的 _id_uuid 将自动生成

      点击阅读更多关于插入元数据的介绍 插入插入覆盖插入更新

      插入边

      图6:通过 UI 操作插入边

      边只有 _uuid 一种唯一标识符,但另有 4 个系统属性,即边起点和终点的唯一标识符 _from&_to_from_uuid&_to_uuid,其中至少一对必须在插入边时提供。

      以下 UQL 均向 schema transfer 中插入了边(由 'CU001' 或 'CU002' 指向 'MC001'):

      // 插入一条边,自定义属性为 null,'_uuid' 由系统生成
      insert().into(@transfer).edges({_from: "CU001", _to: "MC001"})
      
      // 插入两条边,自定义属性为 null,'_uuid' 由系统生成
      insert().into(@transfer).edges([{_from: "CU001", _to: "MC001"},{_from: "CU002", _to: "MC001"}])		
      
      // 插入一条边,'tran_amount' 为 '1000',其他自定义属性为 null,`_uuid` 由系统自动分配
      insert().into(@transfer).edges({_from: "CU001", _to: "MC001", tran_amount: "1000"})
      
      // 插入一条边,'_uuid' 为 '1',自定义属性为 null
      insert().into(@transfer).edges({_from: "CU001", _to: "MC001", _uuid: 1})
      
      // 插入一条边,指定 'tran_amount' 和 '_uuid',其他自定义属性为 null
      insert().into(@transfer).edges({_from: "CU001", _to: "MC001", tran_amount: "Jason", _uuid: "CU001"})
      
      ...
      

      与插点类似,这些插边的 UQL 具有以下特征:

      • 以命令 insert() 为开头
      • 在参数 into() 中声明 schema,在 edges() 中将每个边的属性值组织为对象格式
      • 未提供的自定义属性为 null
      • 未提供的 _uuid 将自动生成
      • 必须提供 _from&_to(或 _from_uuid&_to_uuid),并且这些点必须已经存在

      点击阅读更多关于插入元数据的介绍 插入插入覆盖插入更新

      关于批量导入数据(如 CSV 文件、其他数据库等)的方法,请阅读 数据导入

      更新元数据

      图7:通过 UI 操作更新点

      更多关于更新点、边的 UQL 示例:

      update().nodes().set({type: "IV"})										// 将所有点的 'type' 改为 'IV'
      update().nodes({_id == "CU001"}).set({type: "IV"})						// 将 '_id' 为 'CU001' 的点的 'type' 改为 'IV'
      update().nodes({merchant_name contains "Beijing"}).set({type: "IV"})	// 将 'merchant_name' 中包含 'Beijing' 的点的 'type' 改为 'IV'
      update().edges().set({result: "success"})								// 将所有边的 'result' 改为 'success'
      update().edges({_uuid == 1}).set({result: "success"})					// 将 '_uuid' 为 '1' 的边的 'result' 改为 'success'
      update().edges({@transfer._from == "CU001"}).set({result: "success"})	// 将 '_from' 为 'CU001' 的边的 'result' 改为 'success'
      ...
      

      这些 UQL 语句的特征为:

      • 以命令 update() 为开头
      • 在参数 nodes()edges() 中描述需要更新的点、边(描述方法详见 图数据
      • 在参数 set() 中将点、边的新属性值组织为对象格式,未提供的属性值不变
      • _id_uuid 的值不支持更新

      update() 命令用来更新元数据的属性值,而非对属性进行重命名。对属性、schema、图集进行重命名属于修改图模型的操作,详见 UQL 文档中的 图集Schema属性

      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写