Top 10 HashTags in Cypher Query

Viewed 43

I'm trying to fetch the top 10 unique hashtags used between certain dates from the Twitter dataset. However, if I define WITH again after where it will delete the previous variables, and if I limit the results before where it does not show correct results.

1 Answers

You should try this:

MATCH (h:Hashtag)<-[:TAGS]-(t:Tweet) 
WITH h.tag AS hashtag, date(t.postedTimeStamp) AS PostDate
WHERE date({year:2021, month:8, day:25}) <= PostDate <=date({year:2021, month:8, day:28})
WITH PostDate, hashtag, count(hashtag) AS tagCount
ORDER BY tagCount DESC
RETURN PostDate, COLLECT(hashtag)[0..10] AS tags 
Related