DSL query aggregation question

Dears,

I have some query with aggregation like this:

  "aggs": {
    "NAME": {
      "terms": {
        "script": "doc['si.rc.keyword'].getValue().substring(0,1)",
        "order": {
          "_key": "asc"
        }
        }
      }
    }

the result looks like:

{
  "key" : "0",
  "doc_count":"5436"
},
{
  "key" : "1",
  "doc_count":"7898"
},
{
  "key" : "2",
  "doc_count":"3233"
}

Is there any way to do write such aggregation so that when some case doesn't exist the result will show 0, for example:

{
  "key" : "0",
  "doc_count":"5436"
},
{
  "key" : "1",
  "doc_count":"0"
},
{
  "key" : "2",
  "doc_count":"3233"
}

The si.rc is a text.

Best Regards,
Dan

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.