在Neo4j 2.0之后為cypher語法增加了一些類似於DDL的語法,能夠自己創建索引,約束等等。
有如下的方法可以查詢到當前圖數據庫的索引數量:
neo4j-shell
- 使用:index –indexes列出所有Legacy Index(關於Legacy Index的介紹)
- 使用:schema列出所有label的索引以及約束
- 使用:schema ls -l :YourLabel列出指定標簽的索引與約束
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:
圖片部分是已經試驗可以使用
教程結束,感謝閱讀。
歡迎轉載,但請注明本文鏈接,謝謝。
2016-03-30 20:41:44