# Elastic Search 2.4.1 aggreation query not returning total count

**URL:** <https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683>\
**Category:** Elasticsearch\
**Created:** [November 10, 2016, 3:02pm UTC](https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683 "2016-11-10T15:02:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anantha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anantha](https://discuss.elastic.co/u/Anantha)\
**Post date:** [November 10, 2016, 3:02pm UTC](https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683/1 "2016-11-10T15:02:31Z")

</div>

Hi Team,

We are in the process of migrating our code from elastic search 1.5.2 version to elastic search version 2.4.1. Here is the problem we are facing,  
In ES 1.5.2 we are able to get response the facets field - "total": for the detectedLanuage (which is highlighted below) and while running in ES 2.5.1 we are not getting the facets field -  
"total": for the detectedLanuage (which is highlighted below)

**Note: Both version has different datasets**

Please let me know where i'm are missing.

```
In ES 1.5.2 : 

```

* * *

```
Query 

```

* * *

```
{ 
  "size": 0, 
  "facets": { 
    "@graph.DetectedLanguage": { 
      "terms": { 
        "field": "@graph.DetectedLanguage" 
      } 
    } 
 } 

```

}

## Response

```
 { 
   "took": 40, 
   "timed_out": false, 
   "_shards": { 
   "total": 5, 
   "successful": 5, 
   "failed": 0 
   }, 
    "hits": { 
        "total": 149409, 
        "max_score": 0, 
        "hits": [] 
    }, 

    "facets": { 
        "@graph.DetectedLanguage": { 
            "_type": "terms", 
            "missing": 0, 
            **"total": 747045,** 
            "other": 289, 
            "terms": [ 
                { 
                    "term": "www.xyz.com", 
                    "count": 149409 
                } , 
                { 
                    "term": "iaenlp", 
                    "count": 149409 
                } , 
                { 
                    "term": "http", 
                    "count": 149409 
                } , 
                { 
                    "term": "detectedlanguage", 
                    "count": 149409 
                } , 
                { 
                    "term": "english", 
                    "count": 146779 
                } , 
                { 
                    "term": "dutch", 
                    "count": 1224 
                } , 
                { 
                    "term": "italian", 
                    "count": 488 
                } , 
                { 
                    "term": "german", 
                    "count": 390 
                } , 
                { 
                    "term": "spanish", 
                    "count": 130 
                } , 
                { 
                    "term": "danish", 
                    "count": 109 
                } 
            ] 
        } 
    } 
} 

```

* * *

## In ES 2.4.1

## Query

```
{ 
  "size": 0, 
  "aggs": { 
    "@graph.DetectedLanguage": { 
      "terms": { 
        "field": "@graph.DetectedLanguage" 
      } 
    } 
  } 
} 

```

## Response

```
{ 
"took": 10, 
"timed_out": false, 
  "_shards": { 
        "total": 5, 
        "successful": 5, 
        "failed": 0 
    }, 
    "hits": { 
        "total": 100, 
        "max_score": 0, 
        "hits": [] 
    }, 
    "aggregations": { 
        "@graph.DetectedLanguage": { 
            "doc_count_error_upper_bound": 0, 
            "sum_other_doc_count": 0, 
            "buckets": [ 
                { 
                    "key": "detectedlanguage", 
                    "doc_count": 100 
                } 
                , 
                { 
                    "key": "http", 
                    "doc_count": 100 
                } 
                , 
                { 
                    "key": "iaenlp", 
                    "doc_count": 100 
                } 
                , 
                { 
                    "key": "www.xyz.com", 
                    "doc_count": 100 
                } 
                , 
                { 
                    "key": "english", 
                    "doc_count": 98 
               } 
               , 
                { 
                    "key": "dutch", 
                    "doc_count": 2 
                } 
            ] 
        } 
    } 
}
```

---

<div class="post-metadata">

**Author:** ![karthiga\_sivaraman](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@karthiga\_sivaraman](https://discuss.elastic.co/u/karthiga_sivaraman)\
**Post date:** [November 11, 2016, 6:44am UTC](https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683/2 "2016-11-11T06:44:18Z")

</div>

Is there a option to sum-up the doc\_count of buckets in ES 2.4.1 ?

---

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [November 11, 2016, 9:04am UTC](https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683/3 "2016-11-11T09:04:06Z")

</div>

Try the cardinality aggregation: [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-metrics-cardinality-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-metrics-cardinality-aggregation.html)

---

<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:** [December 9, 2016, 9:04am UTC](https://discuss.elastic.co/t/elastic-search-2-4-1-aggreation-query-not-returning-total-count/65683/4 "2016-12-09T09:04:14Z")

</div>

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