I am currently using neo4j 2.2.5
. I have around 30 million real flights and around thousands airport. I have Flight
and Airport
nodes and also I have HAS_FLIGHT
and FLYING_TO
relationships. Those relationships are connected the two nodes, source Airport
node has connected with Flight
node by HAS_FLIGHT
relationship and Flight
nodes has connected by FLYING_TO
relationship with destination Airport
.
So my question is when I tried to find the path flight from London city to Tokyo city with maximum 2 layovers airports or transit airports, my query will take more than 20 minutes and finally the connection is lost.
Here is my query:
//Flights path from London to Tokyo
MATCH path = (london :Airport{city:'London'})-[:HAS_FLIGHT|FLYING_TO*0..6]->(tokyo :Airport{city:'Tokyo'})
RETURN path;
:Airport(city)
? In general, see this blog post for information on optimizing Cypher queries. – William Lyon