# How to display other count of genres

**URL:** <https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384>\
**Category:** Elasticsearch\
**Created:** [December 28, 2017, 5:21am UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384 "2017-12-28T05:21:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [December 28, 2017, 5:21am UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384/1 "2017-12-28T05:21:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [December 28, 2017, 6:51pm UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384/2 "2017-12-28T18:51:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [December 29, 2017, 2:39am UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384/3 "2017-12-29T02:39:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [December 29, 2017, 8:35am UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384/4 "2017-12-29T08:35:21Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 26, 2018, 8:35am UTC](https://discuss.elastic.co/t/how-to-display-other-count-of-genres/113384/5 "2018-01-26T08:35:28Z")

</div>

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