Book Image

Neo4j Graph Data Modelling

Book Image

Neo4j Graph Data Modelling

Overview of this book

Table of Contents (16 chapters)
Neo4j Graph Data Modeling
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Fetching hotels


Hotels can be found on the basis of which airport are they connected to, as shown in the following query:

neo4j-sh (?)$ MATCH (airport:Airport)-[:HAS_HOTEL]->(hotel:Hotel) 
WHERE airport.code IN ["JFK", "LAX"]
RETURN airport.code, hotel.name, hotel.price;

The output of the preceding query is as follows:

+-----------------------------------------------------+
| airport.code | hotel.name             | hotel.price |
+-----------------------------------------------------+
| "JFK"        | "Hampton Inn"          | 70          |
| "JFK"        | "Fairfield Inn"        | 80          |
| "LAX"        | "LAX South Travelodge" | 93          |
| "LAX"        | "Sheraton"             | 170         |
| "LAX"        | "Concourse"            | 100         |
+-----------------------------------------------------+
5 rows

Although we can find hotels while searching for flights, it is not necessary. Once the flights have been selected, this is an additional step that gives the travelers some...