Reputation: 5853
I am working on this query, where I have to find a path from a node to a given list of nodes and a given list of relationships.
The problem is that WHERE type(rel) in foundRels
I want to iterate over this list and do a fuzzy string match and not an exact string match, but I am not able to iterate over 2 lists.
This is my Cypher query.
MATCH path=(`C1`: COMPETENCY { name: 'C1' })-[*]->(e2)
WITH ['TRAVEL_TO'] as foundRels, ['CHENNAI'] as foundNodes
WHERE ANY (rel in relationships(path) WHERE type(rel) in foundRels)
AND ANY (node in nodes(path) WHERE node.name in foundNodes)
RETURN apoc.path.elements(path) as pathElements
Hope it gives some idea.
Upvotes: 0
Views: 585
Reputation: 12704
Use the function 'contains' and 'unwind'. Unwind will expand your list into rows and contains will search for a string in type(rel). Add below script into your query.
UNWIND foundRels as fRel
WITH foundNodes
WHERE ANY (rel in relationships(path) WHERE type(rel) contains fRel)
Upvotes: 1