概述
属性索引简称为索引(Index),索引的名称和所属的schema与其参照的属性相同。
查看索引
返回的表名:_nodeIndex
、_edgeIndex
返回的表头:name
| properties
| schema
| status
| size
(索引名称、参照属性、所属schema、状态、长度-字节)
索引状态有creating(创建中)和done(已创建)。
// 查看当前图集中的所有索引(结果分点、边两个表返回)
show().index()
// 查看当前图集中的所有点索引
show().node_index()
// 查看当前图集中的所有边索引
show().edge_index()
创建索引
系统属性以及decimal类型的属性不支持创建索引。
// 在当前图集中为指定点schema的指定属性创建索引
create().node_index(@<schema>.<property>)
// 在当前图集中为所有点schema的指定属性(如有)创建索引
create().node_index(@*.<property>)
// 在当前图集中为指定边schema的指定属性创建索引
create().edge_index(@<schema>.<property>)
// 在当前图集中为所有边schema的指定属性(如有)创建索引
create().edge_index(@*.<property>)
// 同时创建多个点/边属性的索引
create()
.node_index(@<schema>.<property>)
.node_index(@*.<property>)
.edge_index(@<schema>.<property>)
.edge_index(@*.<property>)
...
本例为@card点的balance属性创建索引:
create().node_index(@card.balance)
本例为@transaction边的amount属性创建索引:
create().edge_index(@transaction.amount)
删除索引
删除一个属性时,其索引也会同时被删除。
// 从当前图集中删除指定点schema和属性的索引
drop().node_index(@<schema>.<property>)
// 从当前图集中删除所有点schema指定属性(如有)的索引
drop().node_index(@*.<property>)
// 从当前图集中删除指定边schema和属性的索引
drop().edge_index(@<schema>.<property>)
// 从当前图集中删除所有边schema指定属性(如有)的索引
drop().edge_index(@*.<property>)
// 同时删除多个点/边属性的索引
drop()
.node_index(@<schema>.<property>)
.node_index(@*.<property>)
.edge_index(@<schema>.<property>)
.edge_index(@*.<property>)
...
本例删除@card点的balance属性索引:
drop().node_index(@card.balance)
本例删除@transaction边的amount属性索引:
drop().edge_index(@transaction.amount)