Variables declared inside the repeated segment of a quantified path are bound to a list of elements (nodes or edges) encountered across the hops. These are called group variables.
Referencing Outside the Quantified Segment
Outside the parenthesized repeatable group, the variable is exposed as a list. Evaluating property lookups directly on them (e.g., w.level) will fail because list types do not have these properties.
-- SYNTAX ERROR (w and s are lists of elements!)
MATCH p = ((w:Wizard)-[e:Teaches]->(s:Spell)){1,2}
WHERE w.level > 50
RETURN p
-- CORRECT (Filtering using list functions or subqueries)
MATCH p = ((w:Wizard)-[e:Teaches]->(s:Spell)){1,2}
RETURN p, w, s
Referencing Inside the Quantified Segment
Inside the repeatable group, variables are treated as singletons representing the individual nodes or edges at each specific hop. You can filter them inline.
Find paths of 1 to 2 wizard-spell teachings where each teaching wizard has a magic level greater than 40:
MATCH p = ((w:Wizard WHERE w.level > 40)-[:Teaches]->(s:Spell)){1,2}
RETURN p