Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Created December 2, 2019 16:34
Show Gist options
  • Save vladbatushkov/b30c0397cf85af6def4d29cd95f4028c to your computer and use it in GitHub Desktop.
Save vladbatushkov/b30c0397cf85af6def4d29cd95f4028c to your computer and use it in GitHub Desktop.
Iterative flights
WITH { date: "20200101" } as params
UNWIND [[{code: 'BKK'}, { code: 'KIX'}], [ { code: 'KIX'}, {code: 'LAX'}]] as pair
CALL apoc.cypher.run("MATCH (ad:AirportDay { code: \"" + pair[0].code + "_" + params.date + "\" })-[:" + pair[0].code + "_FLIGHT]->(f:Flight)-[:" + pair[0].code + "_FLIGHT]->(bd:AirportDay { code: \"" + pair[1].code + "_" + params.date + "\" }) MATCH (f)-[:OPERATED_BY]->(a:Airline) RETURN f as flight, a as company, ($pair[0].code + $pair[1].code) as key", { pair: pair }) yield value
WITH pair, collect(distinct value) as flights
RETURN *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment