How to create an index on a property of a relation

前提是你 提交于 2019-12-25 16:27:10

问题


I need a query to fetch all properties of a relation that are not empty, e.g.

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?

Or is it not necessary to create an index on a relation property?

I am using neo4j 2.2.3.


回答1:


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.



来源:https://stackoverflow.com/questions/31563680/how-to-create-an-index-on-a-property-of-a-relation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!