Last active
December 5, 2016 15:06
-
-
Save aurbano/48fb6827e961b0be34c5 to your computer and use it in GitHub Desktop.
Neo4j: Return paths that contain only 1 node with a given property
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Match all the paths you are interested in, store them as p | |
// then set n.property to the appropriate value. | |
// the final 1 means how many nodes with that property/value you want in the paths | |
MATCH p=(c)-[:REL_TYPE*]-(n) | |
WHERE LENGTH(FILTER(n IN EXTRACT(n IN nodes(p) | n) WHERE n.property = "value"))=1 | |
RETURN DISTINCT n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment