Skip to content

Instantly share code, notes, and snippets.

@jexp
Last active May 11, 2026 11:53
Show Gist options
  • Select an option

  • Save jexp/2014efa6448b307c65e9 to your computer and use it in GitHub Desktop.

Select an option

Save jexp/2014efa6448b307c65e9 to your computer and use it in GitHub Desktop.
Restaurant Recommendation GraphGist

Restaurant Recommendations

We want to demonstrate how easy it is to model a domain as a graph and answer questions in almost natural language.

Graph Based Search and Discovery is prominent a use-case for graph databases like Neo4j.

Here we use a Domain of restaurants which serve cuisines and are located in a City.

sushi restaurants nyc

The domain diagram was created with the Arrows tool

Setup: Creating Friends, Restaurants in Cities and their Cusines

CREATE (philip:Person {name:"Philip"})-[:IS_FRIEND_OF]->(emil:Person {name:"Emil"}),
       (philip)-[:IS_FRIEND_OF]->(michael:Person {name:"Michael"}),
       (philip)-[:IS_FRIEND_OF]->(andreas:Person {name:"Andreas"})
create (sushi:Cuisine {name:"Sushi"}), (nyc:City {name:"New York"}),
       (iSushi:Restaurant {name:"iSushi"})-[:SERVES]->(sushi),(iSushi)-[:LOCATED_IN]->(nyc),
       (michael)-[:LIKES]->(iSushi),
       (andreas)-[:LIKES]->(iSushi),
       (zam:Restaurant {name:"Zushi Zam"})-[:SERVES]->(sushi),(zam)-[:LOCATED_IN]->(nyc),
       (andreas)-[:LIKES]->(zam)

Philips Friends

MATCH (philip:Person {name:"Philip"})-[:IS_FRIEND_OF]-(person)
RETURn person.name

Restaurants in NYC and their cusines

MATCH (nyc:City {name:"New York"})<-[:LOCATED_IN]-(restaurant)-[:SERVES]->(cusine)
RETURN nyc, restaurant, cusine

Graph Search Recommendation

We want to answer the following question

"" Find Sushi Restaurants in New York that my friends like. ""

sushi restaurants nyc

To satisfy this question, we have to know who’s asking: Philip and he’s asking for 4 connected facts

  • People that are friends of Philip

  • Restaurants located in New York

  • Restaurants that server Sushi

  • Restaurants that his Friends like

MATCH (philip:Person {name:"Philip"}),
      (philip)-[:IS_FRIEND_OF]-(friend),
      (restaurant:Restaurant)-[:LOCATED_IN]->(:City {name:"New York"}),
      (restaurant)-[:SERVES]->(:Cuisine {name:"Sushi"}),
      (friend)-[:LIKES]->(restaurant)
RETURN restaurant.name, collect(friend.name) as likers, count(*) as occurence
ORDER BY occurence DESC
@ericwillie385-byte
Copy link
Copy Markdown

GitHub gists are surprisingly useful for sharing quick ideas, code snippets, and technical experiments without building a full project around them. A lot of developers appreciate clean structure and easy navigation when reviewing shared resources because it saves time during troubleshooting or learning. I notice the same thing with well-organized websites in other spaces too. For example, https://outbacksmenu.us/ keeps large amounts of information simple to browse, which makes the experience feel much smoother instead of overwhelming people with clutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment