所以,我正在尝试使用DSL重新编写以下Cypher。
match (n)
where n.code =~ {prefix}
and n.code =~ '.*-(\\d+){5}'
with n.code as text,
'-' as mark
with reduce(
last = 0, pos in range(0, length(text) - 1) |
case substring(text, pos, length(mark))
when mark then pos
else last
end
) as idx,
text
return substring(text, idx + 1) as next
order by next desc
limit 1
基本上这个想法是:
我无法找到任何FunctionExpression来创建REDUCE。 我错误地看着它吗?或者它是否尚未在2.1.4中实施 我对此的依赖如下:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl</artifactId>
<version>2.1.4</version>
</dependency>
答案 0 :(得分:0)
使用split function可能有一种更简单的方法。
你可以这样做:
with split('XXXXX-00000', '-') as parts return parts[0], parts[1];
那怎么样:
MATCH (n)
WITH n, split(n.code, '-') as parts
WHERE parts[0] = {prefix}
return parts[1] order by parts[1] limit 1;