扫码一下
查看教程更方便
neo4j sql 支持节点或关系属性上的索引以提高应用程序的性能。 我们可以为具有相同标签名称的所有节点的属性创建索引。
我们可以在 match
或 where
或 in
运算符上使用这些索引列来改进 cql 命令的执行。
在本章中,我们将讨论如何
neo4j cql 提供 create index
命令来在节点或关系属性上创建索引。
以下是在 neo4j 中创建索引的语法。
create index on:label (node)
在继续示例之前,创建一个节点 dhawan,如下所示。
create (dhawan:player{name: "shikar dhawan", yob: 1995, pob: "delhi"})
以下是一个 cql 示例 ,用于在 neo4j 中的节点 dhawan 上创建索引。
create index on:player(dhawan)
执行完成后,我们将得到以下结果。
neo4j cql 提供 drop index
命令来删除节点或关系属性的现有索引。
以下是在 neo4j 中创建索引的语法。
drop index on:label(node)
以下是一个 cql 示例,用于在 neo4j 中删除名为“dhawan”的节点上的索引。
drop index on:player(dhawan)
执行完成后,我们将得到以下结果。