Cypher查询未返回匹配项,neo4j中无记录

jm81lzqq  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(224)

我正在建立一个reccomendation搜索查询在cypher我已经产生了以下:

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

我想找到ANGY的最后5个订单,并给予她推荐提供该订单的餐厅。然而,上面的查询返回no matches no records我哪里出错了?请帮助!!!我是NEO4J的新手

watbbzwu

watbbzwu1#

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

最后这对我有用。

相关问题