Aggregation with null values

Is there any way I can get the aggregation with null values?

My Data look like this.

 {"system": "aaa"},
{"system": "bbb"},
{"system": null}

My aggregation query looks like this

{
    "aggs" : {
        "myAggrs" : {
            "terms" : { "field" : "system" }
        } 
}

Expected result is

{
   "key": "aaa",
   "doc_count": 1
},
{
   "key": "bbb",
   "doc_count": 1
},
{
   "key": null,
   "doc_count": 1
}

Hi @Shashi-GS,

you can specify missing in your terms aggregation, e.g.:

{
    "aggs" : {
        "myAggrs" : {
            "terms" : { "field" : "system" },
            "missing": "N/A"
        } 
}

Daniel

Thank you for the response. No actually this will give you the result of separate section of missing count from the aggregation. Hence I don't want to use this. I found the solution for this problem,

While storing the data will use "null_value":"null". From this I can get the aggregation result with null values as well . As per my expectation.

1 Like

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