# Terms aggregations on hashcodes (Murmur3FieldMapper)

**URL:** <https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330>\
**Category:** Elasticsearch\
**Created:** [July 25, 2016, 7:01pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330 "2016-07-25T19:01:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![photonic\_world\_2](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@photonic\_world\_2](https://discuss.elastic.co/u/photonic_world_2)\
**Post date:** [July 25, 2016, 7:01pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/1 "2016-07-25T19:01:25Z")

</div>

Hello,

I have an index (4 shards and 1 replica each) which has high ingestion rate (5k per s) distributed among 5 data nodes.

The problem I see is that when a terms aggregation is run on this index, the response time is very high.

**Mapping** :  
`"recipients": { "type": "string", "index": "not_analyzed", "fields": { "hash": { "type": "murmur3" } } },`

**Aggregation query**

`"aggregations": { "bucket_agg": { "terms": { "field": "recipients.hash", "size": 5, "shard_size": 0, } } }`

But aggregating on hash code is way faster, which is expected as it hashcode fields are not strings and do not need global ordinals to be updated in field data on heavily indexed index.

My problem is that if I query on hash code the value returned by the aggregate is a hashcode, which I am not able to map to the hash code generated from the original string. I used [Mapper code](https://github.com/elastic/elasticsearch/blob/master/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java#L157) to generate hashcode. Can you please let me know if elasticsearch pads or does more optimization to the hash code returned in aggregation?

Thanks!

---

<div class="post-metadata">

**Author:** ![photonic\_world\_2](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@photonic\_world\_2](https://discuss.elastic.co/u/photonic_world_2)\
**Post date:** [July 25, 2016, 9:01pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/2 "2016-07-25T21:01:14Z")

</div>

Looks like the hash code returned as part of the aggregation has 0s padded to the right

Returned by aggregation: 7532129326328174000  
Returned by murmur3: 7532129326328173534

Why and how is the the number rounded up?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 25, 2016, 9:21pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/3 "2016-07-25T21:21:06Z")

</div>

I dunno the answer to this one - I'm not super familiar with aggregations. Rounding a hash code is genuinely weird.

You'll probably have more luck if you just ask the question rather than ping someone directly.

---

<div class="post-metadata">

**Author:** ![photonic\_world\_2](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@photonic\_world\_2](https://discuss.elastic.co/u/photonic_world_2)\
**Post date:** [July 25, 2016, 9:24pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/4 "2016-07-25T21:24:41Z")

</div>

Np.

Apologies. I just added you because I saw you as one of the committers of Mapper code.

Thanks again.

---

<div class="post-metadata">

**Author:** ![photonic\_world\_2](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@photonic\_world\_2](https://discuss.elastic.co/u/photonic_world_2)\
**Post date:** [July 26, 2016, 12:32am UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/5 "2016-07-26T00:32:48Z")

</div>

This turns out is a bug with elasticsearch sense plugin, which rounded off the response hashcodes.

---

<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:33pm UTC](https://discuss.elastic.co/t/terms-aggregations-on-hashcodes-murmur3fieldmapper/56330/6 "2017-07-05T22:33:02Z")

</div>


