'Cypher query returning no matches no records in neo4j
I am building a reccomendation search query in cypher I have produced the following:
LOAD CSV WITH HEADERS FROM "file:///restaurant_data.csv" AS data
MERGE(n1:Customer{Name:data.Name, Latitude:toFloat(data.Latitude),Longitude:toFloat(data.Longitude)})
MERGE(n2:Orders{OrderId:data.Order_ID,OrderTimestamp:data.Order_ts,FoodName:data.Food_Item})
MERGE(n3:Restaurant{RestaurantName:data.Restaurant, RestLat:toFloat(data.Rest_lat), RestLong:toFloat(data.Rest_long)})
MERGE (n1)-[r1:PLACES_ORDER]->(n2)
MERGE (n2)-[r2:BELONGS_TO]->(n3)
MERGE (n3)-[r3:SERVES]->(n2)
RETURN *;
MATCH(n1:Customer{Name:"Angy"})-[:PLACES_ORDER]->(n2:Orders)<-[:SERVES]-(r:Restaurant)
WITH n2 ORDER BY n2.OrderTimestamp DESC LIMIT 5
WITH collect(distinct n2) as orders
MATCH (r:Restaurant) WHERE ALL(order in orders WHERE EXISTS((r)-[:SERVES]->(order)))
RETURN DISTINCT r.RestaurantName
I want to find the last 5 orders of ANGY and give her recommendations of restaurants serving that order. However the above query returns no matches no records
Where am I going wrong? Please help!!! I AM NEW TO NEO4J
Solution 1:[1]
MATCH(:Customer{Name:"Angy"})-[:PLACES_ORDER]->(o:Orders)
WITH o ORDER BY o.OrderTimestamp DESC LIMIT 5
WITH [o.FoodName] as foods
MATCH (r:Restaurant)-[:SERVES]->(n:Orders)
WHERE (n.FoodName in foods)
RETURN distinct r.RestaurantName,foods
Finnally this worked for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | coder_bg |
