# How to get the count of the documents inside term aggregation that have doc\_count as 1?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-count-of-the-documents-inside-term-aggregation-that-have-doc-count-as-1/111753>\
**Category:** Elasticsearch\
**Created:** [December 14, 2017, 11:15am UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-documents-inside-term-aggregation-that-have-doc-count-as-1/111753 "2017-12-14T11:15:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siddaram\_Jamagav](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@Siddaram\_Jamagav](https://discuss.elastic.co/u/Siddaram_Jamagav)\
**Post date:** [December 14, 2017, 11:15am UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-documents-inside-term-aggregation-that-have-doc-count-as-1/111753/1 "2017-12-14T11:15:41Z")

</div>

```
POST alertbrowser/_search?size=0
{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "projectId.keyword": "aasish-webdemo-1-1498031057532"
          }
        }
      ],
      "filter": [{
        "range": {
          "page.time": {
            "gte": "now-M",
            "lte": "now"
          }
        }
      },
      {
          "term":{
            "page.url.keyword":"http://192.168.0.7:8080/WebTest/gallery.html"
          }
        }
      ]
    }
  },
  "aggs": {
    "bouncerate": {
      "terms": {
        "field": "sId.keyword"
      }
    }
  }
}

```

_below is the output of the query the_

```
    {
      "took": 326,
      "timed_out": false,
      "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": 17,
        "max_score": 0,
        "hits": []
      },
      "aggregations": {
        "bouncerate": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 2,
          "buckets": [
            {
              "key": "f65sqj9du1513236322891",
              "doc_count": 3
            },
            {
              "key": "6jlcfm4nj1513157936282",
              "doc_count": 2
            },
            {
              "key": "l337tse5b1512719799692",
              "doc_count": 2
            },
            {
              "key": "qiop98b0n9g951cbl",
              "doc_count": 2
            },
            {
              "key": "c467ag4co1513055629501",
              "doc_count": 1
            },
            {
              "key": "e8y8z1zvl1513054886050",
              "doc_count": 1
            },
            {
              "key": "fp5ouwbj61513158038697",
              "doc_count": 1
            },
            {
              "key": "iiumkslaf1513056775697",
              "doc_count": 1
            },
            {
              "key": "ivy632gaj1512741980096",
              "doc_count": 1
            },
            {
              "key": "krvhewem41513226839187",
              "doc_count": 1
            }
          ]
        }
      }
    }

```

In the above query i aggregated the data based on the sId.keyword. in the output i want to get the count of how many documents inside the bucket have doc\_count as 1?

---

<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 11, 2018, 11:15am UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-documents-inside-term-aggregation-that-have-doc-count-as-1/111753/2 "2018-01-11T11:15:41Z")

</div>

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