Skip to content

Instantly share code, notes, and snippets.

@freeeve
Forked from jexp/restaurant_recommendation.adoc
Last active July 15, 2017 20:14
Show Gist options
  • Save freeeve/1b5d2eef5abb815f96acf773fa8dfff3 to your computer and use it in GitHub Desktop.
Save freeeve/1b5d2eef5abb815f96acf773fa8dfff3 to your computer and use it in GitHub Desktop.
Restaurant Recommendation GraphGist

Restaurant Recommendations

Here’s an updated gist.

Here are some changes.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment