Neo4j 查詢已經創建的索引與約束


在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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM