Neo4j - 是否有密码查询语法来列出(显示)数据库中的所有索引? [英] Neo4j - Is there a cypher query syntax to list (show) all indexes in DB?

查看:11
本文介绍了Neo4j - 是否有密码查询语法来列出(显示)数据库中的所有索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找类似于 MySQL ( SHOW INDEXES ) 的东西.我能够在 Python 中使用 py2neo 获取索引列表

I'm looking for something similar to the MySQL ( SHOW INDEXES ). I was able to get a list of indexes using py2neo in Python

graphDB = neo4j.GraphDatabaseService()
indexes = graphDB.get_indexes(neo4j.Node)
print(format(indexes))

但我想知道是否有办法在 Cypher 中做类似的事情.

but I wanted to know if there's a way to do something similar in Cypher.

推荐答案

还没有.在 Neo4j 2.0 中引入了更密码友好的索引,您可以发出一些 DDL 命令来创建和删除索引和约束,但从 2.01 开始就是这样(参见 文档).在 1.9 中,您根本无法使用 cypher 定义那种类型的架构.

Not yet. In Neo4j 2.0 more cypher friendly indexing was introduced and you can issue some DDL commands to create and drop indices and constraints, but as of 2.01 that's it (see docs). In 1.9 you can't define that type of schema with cypher at all.

--

cypher 之外还有很多方法,比如

There are many ways outside of cypher, for instance

neo4j-shell中你可以

  • 使用 index --indexes
  • 列出旧索引
  • 使用schema
  • 列出所有标签索引和约束
  • 使用 schema ls -l :YourLabel
  • 列出特定标签的索引和约束
  • list legacy indices with index --indexes
  • list all label indices and constraints with schema
  • list indices and constraints for specific label with schema ls -l :YourLabel

neo4j-browser中你可以

  • 使用 :schema 列出所有标签索引和约束
  • 使用 :schema ls -l :YourLabel
  • 列出特定标签的索引和约束
  • list all label indices and constraints with :schema
  • list indices and constraints for specific label with :schema ls -l :YourLabel

大多数允许您执行密码查询的 API 也将提供查询模式的方法,例如

Most APIs that let you execute cypher queries will also provide ways to query schema, such as

  • 原生 Java API
    • GraphDatabaseService.schema().getConstraints().getIndexes() 用于标签模式
    • GraphDatabaseService.index().nodeIndexNames().relationshipIndexNames() 用于旧索引
    • Native Java API
      • GraphDatabaseService.schema().getConstraints() and .getIndexes() for label schema
      • GraphDatabaseService.index().nodeIndexNames() and .relationshipIndexNames() for legacy indices
      • /db/data/schema/ 基于标签架构的端点
      • /db/data/index/node//db/data/index/relationship/ 用于旧索引
      • /db/data/schema/ endpoints for label based schema
      • and to /db/data/index/node/ and /db/data/index/relationship/ for legacy indices

      这篇关于Neo4j - 是否有密码查询语法来列出(显示)数据库中的所有索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆