Skip to content

Instantly share code, notes, and snippets.

@elisedeux
Created December 18, 2018 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elisedeux/125b2eebc47a85a671a0fee6d4aaae56 to your computer and use it in GitHub Desktop.
Save elisedeux/125b2eebc47a85a671a0fee6d4aaae56 to your computer and use it in GitHub Desktop.
// 1) match all disputed transactions
match (p:person)-[b:HAS_BOUGHT_AT {status: "Disputed"}]->(m:merchant)
with
collect(p) as disputer, // list of persons with disputed transactions
collect(b) as disputed, // list disputed transactions
collect(m) as merchants // list merchants with disputed transactions
// 2) match all undisputed transactions
match (p:person)-[b:HAS_BOUGHT_AT {status: "Undisputed"}]->(m:merchant)
where p in disputer // keep only transactions where the buyer is a disputer
with // group undisputed transactions by merchant
collect(p) as mUndisputer, // all persons with undisputed transactions to merchant "m"
collect(b) as mUndisputed, // all undisputed transactions to merchant "m"
m, // merchant m
disputer, disputed, merchants // pervious lists unchanged
where all(d in disputer where d in mUndisputer) // keep only merchants "m" where all disputers belong to the list of undisputers
return disputer, disputed, mUndisputed, m, merchants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment