简体   繁体   English

Neo4j-使用属性开始比赛(REST,Rails,Neo4j 1.98)

[英]Neo4j - use a property to start a match (REST, Rails, Neo4j 1.98)

I want to store node ids in a node for the purpose of caching (For performance reasons - I'm using a linked list which can slow some operations down). 我想将节点ID存储在节点中以进行缓存(出于性能原因-我使用的链表会降低某些操作的速度)。

So something like 所以像

start n=node(1432), author=node(n.author_id)
match author-[:WROTE]-book
return book

Or something like 或类似的东西

start n=node(1432)
with n.author_id match node(n.author_id)-[:WROTE]-book
return book

Now, this might be unorthodox, but again I'm just caching the most recent ID of a user entry into the system. 现在,这可能是不合常规的,但是我再次只是将用户条目的最新ID缓存到系统中。 When there are hundreds or thousands of relationship, it's just quicker to know what node to start from instead of traversing them to find the node to start with. 当存在成​​百上千的关系时,知道遍历从哪个节点开始,而不是遍历遍历以找到开始的节点,就会更快。

I could use parameters but I'm using rest and don't want to have to make 100 rest calls to return 100 of the most recent entries. 我可以使用参数,但是我使用的是rest,并且不想进行100个rest调用来返回100个最新条目。 I'd rather Cypher tackle it all in one trip. 我宁愿Cypher一口气解决所有问题。

Is this possible? 这可能吗?

When relying on node ids be aware that they may be reclaimed when nodes are deleted. 依靠节点ID时,请注意,删除节点后可能会回收它们。

In Neo4j 2.1 the following should work: 在Neo4j 2.1中,以下应该起作用:

START n=node(1432)
WITH n
MATCH (other)-[:WROTE]->(book)
WHERE id(other)=n.author_id
RETURN book

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

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