How to display other count of genres


(張皓翔) #1

Hi everyone, I use genres syntax to query L7_PROTO_NAME and count their in_bytes.
it output the top ten in_bytes L7_PROTO_NAME, then I want to get the top nine L7_PROTO_NAME and "others" . How could I do ?

this is my restful API:

"aggs": {
  "genres":{
    "terms" : {
            "field" : "L7_PROTO_NAME.keyword" ,
            "order" : { "in_bytes" : "desc" }
        },
    "aggs":{
      "in_bytes": {
      "sum": { "field":"IN_BYTES"}
      }
     }
    }
}

thank you in advance!


(Adrien Grand) #2

There is a sum_other_doc_count field, but this doesn't allow you to get the sum of the IN_BYTES field for those other documents.

One workaround could be to run a second request that excludes the top-9 genres and computes the sum of the IN_BYTES field.


(張皓翔) #3

sorry, I have no idea how to get the top-9 genres.
could you please describe how to write restful api.

thank you in advance!!


(Adrien Grand) #4
"aggs": {
  "genres":{
    "terms" : {
            "field" : "L7_PROTO_NAME.keyword" ,
            "order" : { "in_bytes" : "desc" },
            "size": 9
        },
    "aggs":{
      "in_bytes": {
      "sum": { "field":"IN_BYTES"}
      }
     }
    }
}

(system) #5

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