Neo4j: Speed up Relationship matching by property inequality

我的未来我决定 提交于 2019-12-24 08:48:47

问题


I'm using Neo4j 3.0.5.

My query looks as follows:

MATCH (cd:ConnectionDay)-[c:Connection]->()
WHERE id(cd)= { id } AND c.departure <= { departure }
RETURN c

In my graph, the number of Connection relations is very high and I'm looking for a way to speed up the retrieval. Is there a way to create an index for the departure property?

I'm using the Embedded Java API anyway, so solutions that aren't using Cypher are ok, too.


回答1:


Aside: It is not recommended that you use native neo4j IDs to find nodes, as after a node is deleted its native ID can be reused. It is safer to add your own property to store an ID that you know is permanently unique.

Neo4j does not currently support indexing for relationship properties. If you want to use indexing, you can alter you data model to "reify" your Connection relationships as nodes. For example, your new data model would look something like this:

(cd:ConnectionDay)-[:CONNECTS_TO]->(c:Connection {departure: 123})-[]->()


来源:https://stackoverflow.com/questions/39745255/neo4j-speed-up-relationship-matching-by-property-inequality

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