cancel
Showing results for 
Search instead for 
Did you mean: 

Applied Graph Algorithms - Cypher Refresher mistake?

sdennett
Node

In the Cypher Refresher module for the Applied Graph Algorithm Training one of the first tutorial pages has the following:

We’ll start by seeing which cities have the most reviews:

MATCH (c:City) 
RETURN c.name, size((c)<-[:IN_CITY]-()) AS numberOfReviews 
ORDER BY numberOfReviews DESC 
LIMIT 10;

The Yelp Public dataset contains data from a sampling of cities, but we’ll contain our analysis to businesses in the Phoenix area.

Based on the schema, this looks to actually be returning the number of businesses in the returned cities, not the number of reviews. I believe the following would be a more appropriate Cypher query for counting the number of reviews by city:

MATCH (c:City)
RETURN c.name, size((c)<-[:IN_CITY]-(:Business)<-[:REVIEWS]-(:Review)) AS numberOfReviews
ORDER BY numberOfReviews DESC
LIMIT 10;
1 REPLY 1

Hello Steve,

You are absolutely correct. Thank you for pointing this out.

We will correct the browser guide.

Elaine

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.