简体   繁体   English

Cypher -Neo4j在可变长度路径中设置节点属性值

[英]Cypher -Neo4j Set the node attribute value in Variable length paths

I am new to neo4j , I have the following situation 我是neo4j的新手,我有以下情况

match (c:customer{id:'12345'})-[r:buys]->(b:item)
with b,b.total as z
match (b)-[same:*1..z)]->(d)
return d

In the above query z is an integer,But the above query is not working, 在上面的查询中z是一个整数,但是上面的查询不起作用,

I would appreciate all helps and suggestions, Thanks in advance 我将不胜感激所有的帮助和建议,在此先感谢

You cannot use variable for path lengths. 您不能将变量用于路径长度。 A workaround for that would be: 一种解决方法是:

match (c:customer{id:'12345'})-[r:buys]->(b:item)
with b,b.total as z
match p=(b)-[same:*1..9999)]->(d)
where length(p)=z 
return d

Replace the 9999 by a kind of global upper limit suitable for your use case. 用适合您的使用情况的一种全局上限替换9999。 Be warned, this might be pretty inefficient. 请注意,这可能效率很低。 In this case it might be better to send 2 Cypher statements: 在这种情况下,最好发送2个Cypher语句:

match (c:customer{id:'12345'})-[r:buys]->(b:item) return id(b), b.total as z

For the second query insert the value for z via string concatenation: 对于第二个查询,通过字符串串联插入z的值:

match (b)-[same:*1..<z>)]->(d) return d

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

相关问题 Neo4J Cypher:按条件过滤出可变长度路径 - Neo4J Cypher: filter out variable length paths by criteria Cypher (Neo4j) 匹配具有特定长度和值的所有路径 - Cypher (Neo4j) Match all paths with specific length and value Neo4j:在节点标签上具有可变长度和条件的密码查询 - Neo4j: Cypher Query With Variable Length and Condition on Node Labels 用Neo4j Cypher查找给定长度以下的路径,但排除那些将其特定属性设置为特定值的节点的路径 - Finding Paths with Neo4j Cypher Below a Given Length, but Excluding Those with an Nodes with a Specific Property set to a Specific Value 在Cypher Neo4j中查找并计算从一个不超过特定长度的节点开始的所有可能路径 - Find and count all possible paths starting from one node not exceeding specific length in Cypher Neo4j 在Neo4j密码中获取不涉及某些关系的可变长度路径 - Getting variable length paths not involving certain relationships in neo4j cypher 使用可变长度路径时Neo4J Cypher抓取关系的类型 - Neo4J Cypher grabbing type of relations when using variable length paths 在Neo4j中用Cypher设置null值 - Set null value with Cypher in Neo4j Neo4J / Cypher:可变长度的路径模式 - Neo4J/Cypher : variable length of path pattern 如何提高可变长度Neo4j Cypher查询的性能? - How to improve performance on variable length Neo4j Cypher query?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM