Polymorphism
Example 1
Find all Locations (Services + Attractions) connected with Customer with OrderedId 1:
MATCH {class: Customers, as: customer, where: (OrderedId=1)}--{Class: Locations, as: location}
RETURN $pathelements
In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN
clause, this is the obtained graph:
In the Browse Tab of Studio, using 'RETURN location.@Rid as Location_RID, location.Name as Location_Name, location.Type as Location_Type' as RETURN
clause, this is the obtained list of records (only few records are shown in the image below):
Example 2
Find the 3 Hotels that have most reviews:
SELECT
@rid as Hotel_RID,
Name as Hotel_Name,
Type as Hotel_Type,
out("HasReview").size() AS ReviewNumbers
FROM `Hotels`
ORDER BY ReviewNumbers DESC
LIMIT 3
In the Browse Tab of Studio, using the query above, this is the obtained list of records:
In a similar way:
Find the 3 Restaurants that have most reviews:
SELECT
@rid as Restaurant_RID,
Name as Restaurants_Name,
Type as Restaurants_Type,
out("HasReview").size() AS ReviewNumbers
FROM `Restaurants`
ORDER BY ReviewNumbers DESC
LIMIT 3
In the Browse Tab of Studio, using the query above, this is the obtained list of records:
In a polymorphic way:
Find the 3 Services (Hotels + Restaurants) that have most reviews:
SELECT
@rid as Service_RID,
Name as Service_Name,
Type as Service_Type,
out("HasReview").size() AS ReviewNumbers
FROM `Services`
ORDER BY ReviewNumbers DESC
LIMIT 3
In the Browse Tab of Studio, using the query above, this is the obtained list of records: