# Grouping aggregation doc\_count into occurrence summaries

**URL:** <https://discuss.elastic.co/t/grouping-aggregation-doc-count-into-occurrence-summaries/63139>\
**Category:** Elasticsearch\
**Created:** [October 16, 2016, 10:31pm UTC](https://discuss.elastic.co/t/grouping-aggregation-doc-count-into-occurrence-summaries/63139 "2016-10-16T22:31:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Search9212](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Search9212](https://discuss.elastic.co/u/Search9212)\
**Post date:** [October 16, 2016, 10:31pm UTC](https://discuss.elastic.co/t/grouping-aggregation-doc-count-into-occurrence-summaries/63139/1 "2016-10-16T22:31:46Z")

</div>

Thanks in advance for any assistance.

I'm trying to do a second pass on an aggregation to analyze doc\_count. I keep getting:

```
                       Expected [START_OBJECT] under [script], but got a [VALUE_STRING]

```

Is it possible to do this? In my situation I have a bunch of documents with an id field. I'd like to count the occurrences for each unique id (I have this part working).

Next I need to categorize id occurrences such as ...

number of ids that occurred 0-5 times: 10  
number of ids that occurred 6-10 times: 4  
number of ids that occurred more than 10 times: 200

This is the script I have...

{  
"aggs" : {  
"updates\_by\_id": {  
"terms": {  
"script" : "doc['id'].value"  
}  
},  
// the above gives the correct occurences for each id (bucket)  
"id\_ count\_categorizer" : {  
"bucket\_script" : {  
"buckets\_path": {  
"count": "\_count"  
},  
"script": "println(count)" // what goes here?  
},  
"script": "println(count)" // according to the doc I thought this should go here, but it gets ignored  
}  
}  
}

---

<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:11pm UTC](https://discuss.elastic.co/t/grouping-aggregation-doc-count-into-occurrence-summaries/63139/2 "2017-07-05T22:11:54Z")

</div>


