【问题标题】:How to create index on relationship type (neo4j)如何在关系类型上创建索引(neo4j)
【发布时间】:2015-03-08 01:56:14
【问题描述】:

我对 neo4j 很陌生。我在 Windows 下运行 shell。 我创建了一个名为:user 的节点,并且我在 id 上有了索引。用户有 id 和 name 属性。

我创建了一个名为朋友的关系。 (user1, user2)

neo4j.properties 设置为:

# Enable auto-indexing for nodes, default is false
node_auto_indexing=true

# The node property keys to be auto-indexed, if enabled
node_keys_indexable=id

# Enable auto-indexing for relationships, default is false
relationship_auto_indexing=true

# The relationship property keys to be auto-indexed, if enabled
relationship_keys_indexable=user1,user2

我的问题是:

1- 当我输入: :schema ls 时,它显示:

Indexes
  ON :User(id) ONLINE  

No constraints

为什么不显示关系上的索引?

2- 如何使用 shell 手动创建关系索引?

【问题讨论】:

    标签: sql neo4j


    【解决方案1】:

    当您输入:schema 时,您看到的索引是 Neo4j 中的新型索引。似乎 node_auto_indexing 和 relationship_auto_indexing(以及 *_keys_indexable)配置属性是 Neo4j 遗留索引的一部分:

    http://neo4j.com/docs/milestone/auto-indexing.html

    我对遗留索引不太熟悉,但在新式索引中,没有关系索引。在该范例中,您首先通过索引找到节点并从那里跟踪关系,但是如果没有首先找到节点,就无法直接查询关系。

    您可以在此处阅读有关遗留索引的信息:

    http://neo4j.com/docs/milestone/indexing.html

    但我会复制/粘贴一个有用的段落:

    “从 Neo4j 2.0 开始,这不是 Neo4j 中最受欢迎的数据索引方法,而是我们建议在数据库模式中定义索引。”

    “但是,对旧索引的支持仍然存在,因为新索引尚未处理某些功能,例如唯一性约束。”

    不过,我认为这不再是完全正确的,因为 Neo4j 在 DB 模式中支持唯一约束已经有一段时间了:

    http://neo4j.com/docs/stable/query-constraints.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多