Problem cardinality and date_histogram

Hello all,

I have a problem for a answer Elastic Search.

I have 65 doc_count after request done and cardinality give 67 doc_count...

Answer :

"aggregations": {
    "xxxxxxx": {
      "buckets": [
        {
          "key_as_string": "xxxxxxxx",
          "key":xxxxxxxx,
          "doc_count": 65,
          "xxxxx": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": "xxxxxx",
                "doc_count": 63,
                "distinct": {
                  "value": 67
                }
              },
              {
                "key": "xxxxx",
                "doc_count": 2,
                "distinct": {
                  "value": 2
                }
              }
            ]
          }
        }
      ]
    }
  }

Thanks all :slight_smile:

The cardinality aggregation returns approximate counts. In your case, the cardinality agg is below 2 levels of bucket aggregations, so it picks a rather low precision threshold in order to avoid causing out-of-memory errors. You could set a higher precision_threshold in order to get some precision back but note that it might cause out-of-memory issues if the parent aggregations create many buckets.

1 Like

Thanks for the answer.