I want to find a way to re-use a fragment of a Cypher query without doing copy and paste.
Here is a vanilla example query
MATCH path=(ca:City {name:'CityA'})-[*1..3]-(cd:City {name:'CityD'})
WHERE ANY(n IN nodes(path)[1..-1] WHERE n:City AND EXISTS((n)-[:Path]->(:Lake)))
RETURN path
Let's say sometimes I want to do this instead:
MATCH path=(ca:City {name:'CityA'})-[*1..3]-(cd:City {name:'CityD'})
WHERE ANY(n IN nodes(path)[1..-1] WHERE n:City AND EXISTS((n)-[:Path]->(:Lake)))
RETURN nodes(path)
So instead of copy-n-pasting the first two lines, I hope there is a way to re-use them, resulting in something like:
run_common_query_fragment
RETURN relationships(path)
Is there such a thing in neo4j?