Prev |  | Next

## 7.6. Co-favorited places

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.name | count(*)
--- | ---
3 rows
0 ms
`"MelsPlace"` | `2`
`"CoffeShop2"` | `1`
`"SaunaX"` | `1`

### 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.name | collect(tag.name)
--- | ---
3 rows
0 ms
`"MelsPlace"` | `["Cool","Cosy"]`
`"CoffeeShop2"` | `["Cool"]`
`"CoffeeShop3"` | `["Cosy"]`

Copyright © 2013 Neo Technology

Prev | Up | Next
| Home |