# Terms Aggregation on long mapped field (Array) returns different results (elastic 2.3.3 and elastic 2.3.1)

**URL:** <https://discuss.elastic.co/t/terms-aggregation-on-long-mapped-field-array-returns-different-results-elastic-2-3-3-and-elastic-2-3-1/61266>\
**Category:** Elasticsearch\
**Created:** [September 22, 2016, 1:57pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-long-mapped-field-array-returns-different-results-elastic-2-3-3-and-elastic-2-3-1/61266 "2016-09-22T13:57:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Mack](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@Alexander\_Mack](https://discuss.elastic.co/u/Alexander_Mack)\
**Post date:** [September 22, 2016, 1:57pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-long-mapped-field-array-returns-different-results-elastic-2-3-3-and-elastic-2-3-1/61266/1 "2016-09-22T13:57:37Z")

</div>

Hi there,

I was wondering if someone of you folks knows the expected behaviour of the following:

I've added a new mapping on two different clusters.. One field is mapped e.g.:

..."aVirtualCategoryIDs" : {  
"type" : "long",  
"index" : "not\_analyzed"  
},...

The field contains an array of longs.. Both Clusters are feeded with the same data.

Now I'm doing a terms aggregation on it:

....  
""allVCatMatches" : {"  
""terms" : { "field" : "aVirtualCategoryIDs", "size" : 100 }"  
"},"  
....

And I'm getting two different results.

For Cluster A (Elastic Version 2.3.1):

"allVCatMatches" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 18436,  
"buckets" : [ {  
"key" : 200,  
"doc\_count" : 59274  
}, {  
"key" : 59,  
"doc\_count" : 21090  
}, {  
"key" : 60,  
"doc\_count" : 15315  
},

For Cluster B (Elastic Version 2.3.3):

"allVCatMatches" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 17217,  
"buckets" : [ {  
"key" : "200",  
"doc\_count" : 57452  
}, {  
"key" : "59",  
"doc\_count" : 20987  
}, {  
"key" : "60",  
"doc\_count" : 15210  
}, {  
"key" : "9",  
"doc\_count" : 14878  
}, {  
"key" : "89",  
"doc\_count" : 11016  
},

Why is the Key in one result a string and in the other result a integer / long value?

I would be happy about any help!

Thank you very much,

Alex

---

<div class="post-metadata">

**Author:** ![Alexander\_Mack](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@Alexander\_Mack](https://discuss.elastic.co/u/Alexander_Mack)\
**Post date:** [September 23, 2016, 5:58am UTC](https://discuss.elastic.co/t/terms-aggregation-on-long-mapped-field-array-returns-different-results-elastic-2-3-3-and-elastic-2-3-1/61266/2 "2016-09-23T05:58:20Z")

</div>

Hi,

for anyone in future, who has the same problem:

I only focussed on the mapping I had in my .json file (for the cluster / index setup) and was not checking the actual mapping of the index. Doing that using curl -XGET '[http://localhost:9200/YOURINDEXNAME/\_mapping/YOURDOCUMENTTYPE?pretty](http://localhost:9200/YOURINDEXNAME/_mapping/YOURDOCUMENTTYPE?pretty)' I saw, that the mapping was set on string with a whitespace tokenizer 😑

So.. the final solution for me was using the _correct_ json for creating the index.. not the one in some very old branch.. 😉

Cheers,

Alex

---

<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:17pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-long-mapped-field-array-returns-different-results-elastic-2-3-3-and-elastic-2-3-1/61266/3 "2017-07-05T22:17:53Z")

</div>


