I am trying to write a cypher query which allows you to pass in a set of names as strings to find matching nodes and then return each node's id. I've been playing around with the language and came up with the following flawed query:
START person=node(*)
WHERE HAS (person.name)
WITH FILTER (name IN ['ryan','mike'] : person.name=name) AS matchedPersons
RETURN ID(matchedPersons)
Expected `matchedPersons` to be a node or relationship, but it was ``
If I return matchedPersons
instead of ID(matchedPersons)
, I get this result:
+------------------------------------------+
| matchedPersons |
+------------------------------------------+
| ["ryan"] |
| ["mike"] |
| [] |
+------------------------------------------+
3 rows
In my database, I have three person nodes that have the names 'ryan', 'mike', and 'lucy'. I want to get the ID's of the people that match the names in the collection defined in the FILTER clause. How can I get the ID's of each person who has a name that matches at least one of the names in the collection?