简体   繁体   English

Neo4j:通过属性不平等加快关系匹配

[英]Neo4j: Speed up Relationship matching by property inequality

I'm using Neo4j 3.0.5. 我正在使用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. 在我的图中, Connection关系的数量非常多,我正在寻找一种加快检索速度的方法。 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. 无论如何,我都在使用嵌入式Java API,因此不使用Cypher的解决方案也可以。

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. 另外:不建议您使用本机neo4j ID查找节点,因为删除节点后,其本机ID可重复使用。 It is safer to add your own property to store an ID that you know is permanently unique. 添加您自己的属性来存储您知道永久唯一的ID更为安全。

Neo4j does not currently support indexing for relationship properties. Neo4j当前不支持索引关系属性。 If you want to use indexing, you can alter you data model to "reify" your Connection relationships as nodes. 如果要使用索引,则可以更改数据模型以“确认” Connection关系作为节点。 For example, your new data model would look something like this: 例如,您的新数据模型将如下所示:

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

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

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