I have build a small graph where all the screens are connected and the flow of the screen varies based on the system/user. So the system/user is the relationship type.
我已经构建了一个小图表,其中所有屏幕都已连接,并且屏幕流程因系统/用户而异。所以系统/用户是关系类型。
I am looking to fetch all nodes that are linked with a certain relation ship from a starting screen. I don't care about the depth since i don't know the depth of the graph. Something like this, but the below query takes ever to get the result and its returning incorrect connections not matching the attribute {path:'CC'}
我期待从起始屏幕获取与特定关系链接的所有节点。我不关心深度,因为我不知道图的深度。像这样的东西,但下面的查询需要获得结果,并返回不正确的连接不匹配属性{path:'CC'}
match (n:screen {isStart:true})-[r:NEXT*0..{path:'CC'}]-() return r,n
match(n:screen {isStart:true}) - [r:NEXT * 0 .. {path:'CC'}] - ()返回r,n
1 个解决方案
#1
A few suggestions:
一些建议:
-
Make sure you have created an index for
:screen(isStart)
:确保为:screen(isStart)创建了索引:
CREATE INDEX ON :screen(isStart);
- Are you sure you want to include 0-length paths? If not, take out
0..
from your query. -
You did not specify the directionality of the :NEXT relationships, so the DB has to look at both incoming and outgoing :NEXT relationships. If appropriate, specify the directionality.
您没有指定:NEXT关系的方向性,因此DB必须同时查看传入和传出:NEXT关系。如果适用,请指定方向性。
-
To minimize the number of result rows, add a
WHERE
clause that ensures that the current path cannot be extended further.要最小化结果行数,请添加WHERE子句以确保无法进一步扩展当前路径。
您确定要包含0长度路径吗?如果没有,请从查询中取出0 ..
Here is a proposed query that combines the last 3 suggestions (fix it up to suit your needs):
这是一个建议的查询,它结合了最后3个建议(修复它以满足您的需求):
MATCH (n:screen {isStart:true})-[r:NEXT* {path:'CC'}]->(x)
WHERE NOT (x)-[:NEXT {path:'CC'}]->()
return r,n;
#1
A few suggestions:
一些建议:
-
Make sure you have created an index for
:screen(isStart)
:确保为:screen(isStart)创建了索引:
CREATE INDEX ON :screen(isStart);
- Are you sure you want to include 0-length paths? If not, take out
0..
from your query. -
You did not specify the directionality of the :NEXT relationships, so the DB has to look at both incoming and outgoing :NEXT relationships. If appropriate, specify the directionality.
您没有指定:NEXT关系的方向性,因此DB必须同时查看传入和传出:NEXT关系。如果适用,请指定方向性。
-
To minimize the number of result rows, add a
WHERE
clause that ensures that the current path cannot be extended further.要最小化结果行数,请添加WHERE子句以确保无法进一步扩展当前路径。
您确定要包含0长度路径吗?如果没有,请从查询中取出0 ..
Here is a proposed query that combines the last 3 suggestions (fix it up to suit your needs):
这是一个建议的查询,它结合了最后3个建议(修复它以满足您的需求):
MATCH (n:screen {isStart:true})-[r:NEXT* {path:'CC'}]->(x)
WHERE NOT (x)-[:NEXT {path:'CC'}]->()
return r,n;