# Elastic Search Get Numerical Sort Index/Rank of Document

**URL:** <https://discuss.elastic.co/t/elastic-search-get-numerical-sort-index-rank-of-document/17385>\
**Category:** Elasticsearch\
**Created:** [May 7, 2014, 8:49am UTC](https://discuss.elastic.co/t/elastic-search-get-numerical-sort-index-rank-of-document/17385 "2014-05-07T08:49:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![webish](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@webish](https://discuss.elastic.co/u/webish)\
**Post date:** [May 7, 2014, 8:49am UTC](https://discuss.elastic.co/t/elastic-search-get-numerical-sort-index-rank-of-document/17385/1 "2014-05-07T08:49:02Z")

</div>

Knowns:

1. Large set of entity documents
2. Entity documents have large sets of relationship documents (child  
docs)
3. Relationship documents contain a "type" field and field linking to  
another entity document that has the relationship
4. Entity documents use increment functions to maintain aggregate counts  
grouped by each type of relationship document (something like friends:100  
and family:7)
5. Queries are performed to sort and get entity documents by the count  
of a relationship aggregate field "type" (most to least, etc)

Unknown:

1. Need to be able to get the 'rank number' of any entity in the set  
with iterating over the entire set to find it's position (most would be 1  
where least would be number of documents returned for query)

Questions:

- Is there any type of functionality that supports this?

- If not, anyone know of some data architectural techniques to solve  
this?

Thanks in advance!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9214ecf3-55f3-4486-8db7-3be3a75ea924%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9214ecf3-55f3-4486-8db7-3be3a75ea924%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tim\_Schimandle](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@Tim\_Schimandle](https://discuss.elastic.co/u/Tim_Schimandle)\
**Post date:** [May 24, 2016, 5:50pm UTC](https://discuss.elastic.co/t/elastic-search-get-numerical-sort-index-rank-of-document/17385/2 "2016-05-24T17:50:14Z")

</div>

I would also like to hear some discussion around this topic. I am working to solve this issue right now and I cannot identify a nice solution.

I did not realize how old this post was.

---

<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 5, 2017, 10:49pm UTC](https://discuss.elastic.co/t/elastic-search-get-numerical-sort-index-rank-of-document/17385/3 "2017-07-05T22:49:25Z")

</div>


