Neo4j 查询已经创建的索引与约束

本文介绍了Neo4j 2.0之后新增的Cypher语法特性,包括如何创建索引和约束。提供了查询当前图数据库索引数量的方法,并展示了通过不同工具(如neo4j-shell和neo4j-browser)进行索引查询的具体操作步骤。

在Neo4j 2.0之后为cypher语法增加了一些类似于DDL的语法,能够自己创建索引,约束等等。

有如下的方法可以查询到当前图数据库的索引数量:

neo4j-shell 

neo4j-browser

  • 使用::schema 列出所有标签的所有记录

 

  • 使用::schema ls -l :YourLabel列出指定标签的索引与约束

 

大多数APIs都支持使用CQL查询,以下提供两种查询方案

  • Native Java API
public static void main(String[] args) {
        GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File("D:\\neo4j\\HelloWorld3"));
        Transaction beginTx = graphDb.beginTx();
        System.out.println("constraint:" + graphDb.schema().getConstraints(DynamicLabel.label("Test")));
        System.out.println("index:" + graphDb.schema().getIndexes(DynamicLabel.label("Test")));
        beginTx.success();
    }

  • REST calls (这个方法尝试过,行不通)
    • /db/data/schema/ endpoints for label based schema
    • and to /db/data/index/node/ and /db/data/index/relationship/ for legacy indices

以上文内容翻译自stackoverflow:

http://stackoverflow.com/questions/19801599/neo4j-is-there-a-cypher-query-syntax-to-list-show-all-indexes-in-db

图片部分是已经试验可以使用

教程结束,感谢阅读。

欢迎转载,但请注明本文链接,谢谢。

 2016-03-30   20:41:44

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值