Aggregation with null values


(Shash) #1

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
}

(Daniel Mitterdorfer) #2

Hi @Shashi-GS,

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

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

Daniel


(Shash) #3

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.


(system) #4

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