# How we can create leaderboards(ranking) using elasticsearch

**URL:** <https://discuss.elastic.co/t/how-we-can-create-leaderboards-ranking-using-elasticsearch/12127>\
**Category:** Elasticsearch\
**Created:** [May 26, 2013, 12:51pm UTC](https://discuss.elastic.co/t/how-we-can-create-leaderboards-ranking-using-elasticsearch/12127 "2013-05-26T12:51:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maaz\_Bin\_Tariq](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Maaz\_Bin\_Tariq](https://discuss.elastic.co/u/Maaz_Bin_Tariq)\
**Post date:** [May 26, 2013, 12:51pm UTC](https://discuss.elastic.co/t/how-we-can-create-leaderboards-ranking-using-elasticsearch/12127/1 "2013-05-26T12:51:17Z")

</div>

I want to make leaderboard for my website (weekly,monthly,yearly,alltime)  
similar to how stackoverflow leagues are working[http://stackexchange.com/leagues/1/week/stackoverflow](http://stackexchange.com/leagues/1/week/stackoverflow).  
Whats the best way to create users ranking also consider ties? I also want  
to show the current user ranking. I am using java for my app.

I have a two types in an elasticsearch index

1. First type \*user \*where users cumulative points/score is saved structure  
like

user\_id,  
total\_points

1. Second type \*post\_points \*where user points for each post is saved

structure like

user\_id  
post\_id  
points  
date

Users ranking can be calculated using a following elasticsearch range (not  
tested) but how user own ranking also consider ties can be calculated?

{  
"range" : {  
"date" : {  
"gt" : 'week/month/year date'  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:34am UTC](https://discuss.elastic.co/t/how-we-can-create-leaderboards-ranking-using-elasticsearch/12127/2 "2017-07-06T02:34:45Z")

</div>


