cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher syntax suggestion: Relationship pattern predicates

Since Neo4j 4.4, there is a new Cypher syntax Node pattern predicates.

Is it possible to implement similar Relationship pattern predicates as well? It would allow querying for a variable-length path pattern for relationships that have properties designating its validity start/end.

Current query to return friends at a specified date:

MATCH p=(n:Person WHERE id(n) = $id)-[:FRIEND_OF*1..5]-(:Person) WHERE all(r IN relationships(p) WHERE r.dateFrom <= $date AND r.dateTo >= $date) RETURN p

Proposed query:

MATCH p=(n:Person WHERE id(n) = $id)-[r:FRIEND_OF*1..5 WHERE r.dateFrom <= $date AND r.dateTo >= $date]-(:Person) RETURN p

The current query searches for all paths first, which is harmful for performance because it can return lots of paths, and post-filters the result.

The proposed query would apply the condition during the traversal, so that only the matching paths are returned.

1 REPLY 1

@zakjan

This suggestion is interesting,
but I think would be better to create an issue on GitHub page , using the Feature request template ,
otherwise here this hint could be lost forever 😄