小编Dmi*_*rov的帖子

将数组与 Cypher (Neo4j) 结合起来

当我有一个看起来像这样的字符串时:

"app-server/src/test/java/de/something/"

我如何获得任何可能的组合,例如:

app-server/, app-server/src, app-server/src/test, ....

显然我可以用“/”将其分割,然后我就有了一个零件数组。我还可以手动附加所有这些,然后过滤null

...
WITH split(package.path,'/')[..size(split(package.path,'/'))-1]
WITH pathParts,
pathParts[0] AS p01,
pathParts[0] + '/' + pathParts[1] AS p02,
pathParts[0] + '/' + pathParts[1] + '/' + pathParts[2] AS p03,
...
Run Code Online (Sandbox Code Playgroud)

替代:

WITH pathParts[0] AS p01,
reduce(s = pathParts[0], x IN pathParts[1..2] | s + '/' + x) + '/' AS p02,
reduce(s = pathParts[0], x IN pathParts[1..3] | s + '/' + x) + '/' AS p03,
reduce(s = pathParts[0], x IN pathParts[1..4] | …
Run Code Online (Sandbox Code Playgroud)

database arrays graph neo4j cypher

2
推荐指数
1
解决办法
2522
查看次数

标签 统计

arrays ×1

cypher ×1

database ×1

graph ×1

neo4j ×1