简体   繁体   English

如何在关系的属性上创建索引

[英]How to create an index on a property of a relation

I need a query to fetch all properties of a relation that are not empty, eg 我需要一个查询来获取一个不为空的关系的所有属性,例如

MATCH ()-[r:TYPE]-() WHERE r.attr <> "" RETURN r.attr

I would guess that CREATE INDEX ON :TYPE(attr) creates an Index on a Node with the label TYPE and not on a relation property? 我猜想CREATE INDEX ON :TYPE(attr)在带有标签TYPE的节点上创建索引,而不是在关系属性上创建索引?

Or is it not necessary to create an index on a relation property? 还是没有必要在关系属性上创建索引?

I am using neo4j 2.2.3. 我正在使用neo4j 2.2.3。

Indexes on relationships are only possible by using manual indexes . 关系索引只能通过使用手动索引来实现

Bevor creating those I strongly recommend rethinking your graph model. 最好创建那些,我强烈建议您重新考虑您的图形模型。 Everything being an entity or a complex value type should be modeled as nodes. 凡是实体或复杂值类型的事物都应建模为节点。 The interaction between the things in your world are modeled as relationships. 您世界中事物之间的交互被建模为关系。 Typically relationships use weight parameters or metadata for their properties but rarely real attributes. 通常,关系将权重参数或元数据用于其属性,但很少使用真实属性。

Since your queries typically start at "something" (aka a thing aka a node) you most likely don't need relationship indexes. 由于查询通常从“某物”(又称“事物”,又称为“节点”)开始,因此您很可能不需要关系索引。 Indexes should only be used for identifying the start points for your traversals. 索引仅应用于标识遍历的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM