Goal: sort items by popularity using a unit of time (1 hour, 24 hours, week, etc.)
I'm using rethinkdb for storing the likes. To grab the likes of all the users in the past 24 hours, I do something like this:
r.table('users')('likes').between(/*24 hours*/).run()
I then count the times an item appears and put the id of the item in a dictionary along with its like count
I then have to query for the liked items to get all of their information needed for display to a user.
If I do all of this every 5 minutes, I should have the desired results.
Is there a better way to do this with elasticsearch?
Is it easy for me to use elasticsearch with rethinkdb or to move my existing data over to elasticsearch and begin storing it there?