7.6. Co-favorited places

7.6.1. Co-favorited places — users who like x also like y
7.6.2. Co-Tagged places — places related through tags

Figure 7.5. Graph


7.6.1. Co-favorited places — users who like x also like y

Find places that people also like who favorite this place:

  • Determine who has favorited place x.
  • What else have they favorited that is not place x.

Query. 

START place=node:node_auto_index(name = "CoffeeShop1")
MATCH place<-[:favorite]-person-[:favorite]->stuff
RETURN stuff.name, count(*)
ORDER BY count(*) DESC, stuff.name

The list of places that are favorited by people that favorited the start place.

Result

stuff.namecount(*)
3 rows

"MelsPlace"

2

"CoffeShop2"

1

"SaunaX"

1


Try this query live. (1) {"name":"SaunaX"} (2) {"name":"CoffeeShop1"} (3) {"name":"MelsPlace"} (4) {"name":"CoffeeShop3"} (5) {"name":"Cool"} (6) {"name":"CoffeeShop2"} (7) {"name":"CoffeShop2"} (8) {"name":"Cosy"} (9) {"name":"Jill"} (10) {"name":"Joe"} (2)-[:tagged]->(5) {} (2)-[:tagged]->(8) {} (3)-[:tagged]->(8) {} (3)-[:tagged]->(5) {} (4)-[:tagged]->(8) {} (6)-[:tagged]->(5) {} (9)-[:favorite]->(2) {} (9)-[:favorite]->(3) {} (9)-[:favorite]->(7) {} (10)-[:favorite]->(2) {} (10)-[:favorite]->(1) {} (10)-[:favorite]->(3) {} START place=node:node_auto_index(name = "CoffeeShop1") MATCH place<-[:favorite]-person-[:favorite]->stuff RETURN stuff.name, count(*) ORDER BY count(*) DESC, stuff.name

7.6.2. Co-Tagged places — places related through tags

Find places that are tagged with the same tags:

  • Determine the tags for place x.
  • What else is tagged the same as x that is not x.

Query. 

START place=node:node_auto_index(name = "CoffeeShop1")
MATCH place-[:tagged]->tag<-[:tagged]-otherPlace
RETURN otherPlace.name, collect(tag.name)
ORDER BY length(collect(tag.name)) DESC, otherPlace.name

This query returns other places than CoffeeShop1 which share the same tags; they are ranked by the number of tags.

Result

otherPlace.namecollect(tag.name)
3 rows

"MelsPlace"

["Cool","Cosy"]

"CoffeeShop2"

["Cool"]

"CoffeeShop3"

["Cosy"]


Try this query live. (1) {"name":"SaunaX"} (2) {"name":"CoffeeShop1"} (3) {"name":"MelsPlace"} (4) {"name":"CoffeeShop3"} (5) {"name":"Cool"} (6) {"name":"CoffeeShop2"} (7) {"name":"CoffeShop2"} (8) {"name":"Cosy"} (9) {"name":"Jill"} (10) {"name":"Joe"} (2)-[:tagged]->(5) {} (2)-[:tagged]->(8) {} (3)-[:tagged]->(8) {} (3)-[:tagged]->(5) {} (4)-[:tagged]->(8) {} (6)-[:tagged]->(5) {} (9)-[:favorite]->(2) {} (9)-[:favorite]->(3) {} (9)-[:favorite]->(7) {} (10)-[:favorite]->(2) {} (10)-[:favorite]->(1) {} (10)-[:favorite]->(3) {} START place=node:node_auto_index(name = "CoffeeShop1") MATCH place-[:tagged]->tag<-[:tagged]-otherPlace RETURN otherPlace.name, collect(tag.name) ORDER BY length(collect(tag.name)) DESC, otherPlace.name