opencypher.org opencypher.org | [email protected]

Report 2 Downloads 46 Views
opencypher.org | [email protected]

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 | [email protected]

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) 0 AND new.category = old.category RETURN store, count(distinct new) as offers ORDER BY offers

• • •

opencypher.org | [email protected]

• • • • •

opencypher.org | [email protected]

val user=... session.run( "MATCH (u:User {id: $user} RETURN u", Map("user" -> user) ).single()

// ●

<pattern>

● didn't match (u:User {id: 'joe56'} ●

opencypher.org | [email protected]

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) 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 Documents