# Different result for cardinality aggregation \[6.3.0\] in Python 3.6 plugin

**URL:** <https://discuss.elastic.co/t/different-result-for-cardinality-aggregation-6-3-0-in-python-3-6-plugin/148798>\
**Category:** Elasticsearch\
**Created:** [September 17, 2018, 9:18am UTC](https://discuss.elastic.co/t/different-result-for-cardinality-aggregation-6-3-0-in-python-3-6-plugin/148798 "2018-09-17T09:18:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wietse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wietse/32/35597_2.png) [@Wietse](https://discuss.elastic.co/u/Wietse)\
**Post date:** [September 17, 2018, 9:18am UTC](https://discuss.elastic.co/t/different-result-for-cardinality-aggregation-6-3-0-in-python-3-6-plugin/148798/1 "2018-09-17T09:18:59Z")

</div>

Hi

I'm trying to extract every hour the amount of unique users who logged in the past 24 hours. For this I use the cardinality aggregation with a range on the time. I use ELK 6.3.

```
GET logins/_search
{
  "_source": "user_id", 
  "query": {
    "range": {
      "time": {
        "gte": 1537016400.0,
        "lt": 1537102800.0
      }
    }
  },
  "aggs": {
    "unique_users": {
      "cardinality": {
        "field": "user_id"
      }
    }
  }
}

```

This yields me the same result every time, when I raise the precision threshold I get the same result still (254202 unique users).

However, when I execute this query using the Python API (Python 3.6), I get three different results (254202, 202847, 209580 unique users). These values alternate consistently. The correct value is among them, but I need to know which one it is of course. Am I missing something? An extra option in Python? Raising the precision threshold in Python did not help.

Any help is much appreciated.

---

<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:** [October 15, 2018, 9:28am UTC](https://discuss.elastic.co/t/different-result-for-cardinality-aggregation-6-3-0-in-python-3-6-plugin/148798/2 "2018-10-15T09:28:44Z")

</div>

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