Hello! I was hoping that I could solve a problem of extracting one of many possible paths out of neo4j but I'm starting to think this isn't possible. I'd really appreciate any help/pointers.
Goal
We have a few "Place" nodes constructed in the test data below. "People" visit "Place"s one at a time and in doing so, create a parent-child relationship between the places. Each person will have a different path through the places. I want to extract each person's path separately.
Example
Set up some data
with [{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 }] as nodes
unwind nodes as node
create (p:Place) set p += node;
match (one {id: 1})
match (two {id: 2})
match (three {id: 3})
match (four { id: 4 })
match (five { id: 5})
merge (one)<-[:follows { person: 1 }]-(two)
merge (two)<-[:follows { person: 1 }]-(four)
merge (four)<-[:follows { person: 1 }]-(three)
merge (three)<-[:follows { person: 1 }]-(five)
merge (one)<-[:follows { person: 2 }]-(two)
merge (two)<-[:follows { person: 2 }]-(three)
merge (three)<-[:follows { person: 2 }]-(four)
merge (four)<-[:follows { person: 2 }]-(five)
With the following query, I'm expecting edges to not be returned if they have a person
property that is not 1. This doesn't happen - all edges are returned between the matching nodes.
match (tail:Place)
where not exists {
match (tail)<-[:follows {person: 1}]-()
}
with tail
match p=(tail)-[*1..2 { person: 1 }]-()
return p
Is this possible?