Anuj Chopra
Anuj Chopra

Reputation: 1

Query needed for neo4j

Hey guys i needed some help in framing this query in neo4j.

Rank all artists (music artists) by the unique number of listening users, display the top 5.

Thanks

Graph is like this:

(User)-[:LISTENS_TO{weight:1212}]->(artists),
(User)-[:TAGS]->(artists),
(User)-[:FRIENDS_WITH]->(friend)

Query that i think might work :

match (m : user) - [l : listnto ] - > a : aryist
return count (distinct (m ) )as listncount , a.name order by lostencount desc limit {5}

Upvotes: 0

Views: 33

Answers (1)

Luanne
Luanne

Reputation: 19373

Created a small graph sample here: http://console.neo4j.org/r/ujhh0x

The query

MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
RETURN a.name,count(DISTINCT u) AS count
ORDER BY count DESC
LIMIT 5

returns artists ordered by the number of unique listeners.

Upvotes: 2

Related Questions