Elastic Search 2.4.1 aggreation query not returning total count

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 
                } 
            ] 
        } 
    } 
}

Is there a option to sum-up the doc_count of buckets in ES 2.4.1 ?

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

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