Filter a Query with a variable-length relationship

Hi

Given this query:

MATCH (a:Agent {name: 'Robert Adam'})-[r*1..2]-(b)
RETURN  r, a, b

Is there a way to filter this result to get only paths with relationships with a specific property value and keep having a graph with multiple levels? for example:

MATCH (a:Agent {name: 'Robert Rizzie'})-[r*1..2]-(b)
where r.total>1
RETURN  r, a, b

Thank you

You can use quantified paths:

MATCH (a:Agent {name: 'Robert Rizzie'})
MATCH (a)(()-[r]-() where r.total>1){1,2}(b)
RETURN  r, a, b

Or a WHERE clause outside the match:

MATCH (a:Agent {name: 'Robert Rizzie'}) 
MATCH path=(a)-[*1..2]-(b) 
WHERE All(i in relationships(path) where i.total>1)
RETURN a, relationships(path), b

The quantified path solution is more efficient since the predicate is evaluated during traversal, while the WHERE predicate is evaluated after each matching path is found.

Thank you for your helpful response
It also gives me hints for other investigations :thinking:.