Of course, what you want to do is similar to being in a SQL query.
In cypher, you can link query segments and use the results of the previous parts in the next part with WITH , see the manual.
For your example, one might assume:
START n=node(1) MATCH n-[rel:street*]-x WITH SUM(rel.distance) as distance WHERE distance < 100 RETURN x
Unfortunately, the amount does not work with collections yet
So I tried to do it differently (for variable length paths):
START n=node(1) MATCH n-[rel:street*]-x WITH collect(rel.distance) as distances WITH head(distances) + head(tail(distances)) + head(tail(tail(distances))) as distance WHERE distance < 100 RETURN x
Unfortunately, the head of an empty list does not return null , which can be coalesce d to 0 , but just fails. So this approach will only work for fixed-length paths, I don't know if this works for you.
source share