Grouping aggregation doc_count into occurrence summaries

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
}
}
}

1 Like