opencypher.org opencypher.org | opencypher@googlegroups.com
val user=... val product=... val city=.... Stores from city that offer products from the same brand and category as product that are on stock opencypher.org opencypher.org | opencypher@googlegroups.com
MATCH (u:User {id: $user}) MATCH (old:Product {id: $product})-[:BOUGHT]->(u) MATCH (store)-[:IN]->(c:City {name: $city}), (store)-[:SELLS]->(new:Product), (new)-[:MADE_BY]->(brand)<-[:MADE_BY]-(old) WHERE new.avail > 0 AND new.category = old.category RETURN store, count(distinct new) as offers ORDER BY offers
• • • opencypher.org opencypher.org | opencypher@googlegroups.com
• • • • • opencypher.org opencypher.org | opencypher@googlegroups.com
val user=... session.run( " MATCH (u:User {id: $user} RETURN u", Map("user" -> user) ).single() // <- This fails if no user is found ... opencypher.org opencypher.org | opencypher@googlegroups.com
● ● ● ● ● opencypher.org opencypher.org | opencypher@googlegroups.com
● ● ● ● ● opencypher.org opencypher.org | opencypher@googlegroups.com
MANDATORY MATCH <pattern> ● <pattern> ● didn't match (u:User {id: 'joe56'} ● opencypher.org opencypher.org | opencypher@googlegroups.com
MANDATORY MATCH (u:User {id: $user}) MANDATORY MATCH (c:City {name: $city}) MANDATORY MATCH (old:Product {id: $product})-[:BOUGHT]->(u) MATCH (store)-[:IN]->(c)-[:SELLS]->(new:Product), (new)-[:MADE_BY]->(brand)<-[:MADE_BY]-(old) WHERE new.avail > 0 AND new.category = old.category RETURN store, count(distinct new) as offers ORDER BY offers
MANDATORY { MATCH (u:User {id: $user}) MATCH (c:City {name: $city}) MATCH (old:Product {id: $product})-[:BOUGHT]->(u) RETURN * } ...
MANDATORY { MATCH ... RETURN ... UNION MATCH ... RETURN ... } RETURN ...
● MANDATORY MATCH ● ● ● ●
Recommend
More recommend