How does the where condition in neo4j works ?
I have simple data set with following relationship =>
Client -[CONTAINS {created:"yesterday or today"}]-> Transaction -[INCLUDES]-> Item
I would like to filter above to get the items for a transaction which were created yesterday, and I use the following query -
Match
(c:Client) -[r:CONTAINS]-> (t:Transaction),
(t) -[:INCLUDES]-> (i:Item)
where r.created="yesterday"
return c,t,i
But it still returns the dataset without filtering. What is wrong ? And how does the filtering works in neo4j for multiple MATCH statements say when I want to run my query on filetered dataset from previous steps?
Thank you very much in advance.
Your query seems fine to me. However, there are 2 things I would like to point out here:
WHEREclause can be removed and use match by property instead.MATCHclause can be combined.So, the query would be:
Regarding your second question, when you want to run another query on the filtered dataset from the previous step, use
WITHcommand. Instead of returning the result,WITHwill pipe your result to the next query.For example, with your query, we can do something like this to order the result by client name and return only the client: