Reputation: 35
I have the following statement:
MATCH path=(p:Person {person_id: '123'})-[:ASSOCIATED_WITH]-(:Person)
where exists((p)-[:BELONGS]-(:Face)-[:CORRESPONDS]-(:Image)-[:HAS_ACCESS_TO]-(:Dias {group_name: 'group'}))
RETURN path
It returns 3 nodes, 2 relationships. This is what I would like to happen but the group_name I will actually be passing is an array. How do I add the condition to check for the value in the array while still maintaining 3 nodes and two relationships? The only relationship I want to return back is ASSOCIATED_WITH. The 3 nodes being, the main person_id of "123" and the two associated persons.
Upvotes: 0
Views: 52
Reputation: 66957
I will assume you pass the list of group names in a names
parameter.
If you want to get the paths in which the EXISTS test succeeds for ANY name in the list:
MATCH (p:Person {person_id: '123'})
WHERE ANY(x IN $names WHERE
EXISTS((p)-[:BELONGS]-(:Face)-[:CORRESPONDS]-(:Image)-[:HAS_ACCESS_TO]-(:Dias {group_name: x})))
MATCH path=(p)-[:ASSOCIATED_WITH]-(:Person)
RETURN path
Or, if you want to get the paths in which the EXISTS test succeeds for ALL names in the list, just replace ANY
in the above request with ALL
:
MATCH (p:Person {person_id: '123'})
WHERE ALL(x IN $names WHERE
EXISTS((p)-[:BELONGS]-(:Face)-[:CORRESPONDS]-(:Image)-[:HAS_ACCESS_TO]-(:Dias {group_name: x})))
MATCH path=(p)-[:ASSOCIATED_WITH]-(:Person)
RETURN path
Upvotes: 1