# ElasticSearch Hash Function

**URL:** <https://discuss.elastic.co/t/elasticsearch-hash-function/21420>\
**Category:** Elasticsearch\
**Created:** [December 29, 2014, 11:48am UTC](https://discuss.elastic.co/t/elasticsearch-hash-function/21420 "2014-12-29T11:48:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![costya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costya/32/751_2.png) [@costya](https://discuss.elastic.co/u/costya)\
**Post date:** [December 29, 2014, 11:48am UTC](https://discuss.elastic.co/t/elasticsearch-hash-function/21420/1 "2014-12-29T11:48:38Z")

</div>

Hi,

I would like to predict the shards routing of a set of keys as a function  
of the number of shards,without defining the actual index.  
Elasticsearch Version 1.4.2

How can i check which hash function is used for routing ? and how can i  
check it inside my java program ?

Thanks,  
Costya

--  
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/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 29, 2014, 3:18pm UTC](https://discuss.elastic.co/t/elasticsearch-hash-function/21420/2 "2014-12-29T15:18:04Z")

</div>

For ES 1.4, see

> <https://github.com/elastic/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java#L265>

and the hash function is

> <https://github.com/elastic/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/cluster/routing/operation/hash/djb/DjbHashFunction.java>

Note, the hash function will change in ES 2.0.

You can not check from outside what hash function ES uses, this is internal  
use only.

Jörg

On Mon, Dec 29, 2014 at 12:48 PM, Costya Regev [costya@totango.com](mailto:costya@totango.com) wrote:

> Hi,
> 
> I would like to predict the shards routing of a set of keys as a  
> function of the number of shards,without defining the actual index.  
> Elasticsearch Version 1.4.2
> 
> How can i check which hash function is used for routing ? and how can i  
> check it inside my java program ?
> 
> Thanks,  
> Costya
> 
> --  
> 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/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoGLciGr6QEKDy\_PLAU2v68aXNGHXf5gmN1w9Xb8aq%2BtnQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGLciGr6QEKDy_PLAU2v68aXNGHXf5gmN1w9Xb8aq%2BtnQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:41am UTC](https://discuss.elastic.co/t/elasticsearch-hash-function/21420/3 "2017-07-06T00:41:34Z")

</div>


