cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Alternative Filter using list (Dynamic Approach)

Im trying to filter based on a list that will be applicable to a general filter as long the list has the properties of the node, its trying to filter for.

UNWIND [{id:'1002',name:'Ford', type:'4-wheel'}] as row
MATCH (c:Car)
WHERE c[head(keys(row))]=row[head(keys(row))]
return c

My problem is that the query filters as OR boolean and not AND boolean. (i.e. the reults return any combination of the property of node). However I just want the node that has all the properties listed.

2 REPLIES 2

ameyasoft
Graph Maven
Try this:

UNWIND [{id:'1002',name:'Ford', type:'4-wheel'}] as row
MATCH (c:Car) where exists(c.id) and exists(c.name) and exists(c.type)
and c.id = row.id and c.name = row.name and c.type = row.type
return c

The query u gave will achieve what im asking but this is hard coding the values. I am looking for a more dynamic/general approach that will work with other nodes. So this will work for all filters as long what is in the list is the property of the node you are trying to filter.