ES cardinality got zero when set precision_threshold large

Hello,
My elasticsearch' version is 6.2.4, like the title said, there is something wrong with the cardinality aggregation. When I change the precision_threshold from 300 to 10000, I got zero for the cardinality. I suppose that the higher the precision_threshold will lead to a more accurate result, but the only I can get is zero. Below is the code:

    dsl={
  'query': {
    'bool': {
      'must': [
        {
          'range': {
            'created': {
              'gte': '2019-04-30',
              'lte': '2019-04-30',
              'format': 'yyyy-MM-dd',
              'time_zone': '+08:00'
            }
          }
        },
        {
          'terms': {
            'app_name': [
              'vip-mini'
            ]
          }
        },
        {
          'terms': {
            'current_page': [
              'detail'
            ]
          }
        },
        {
          'terms': {
            'event_type': [
              'pv'
            ]
          }
        }
      ]
    }
  },
  'aggs': {
    'my_buckets': {
      'composite': {
        'size': 9999999,
        'sources': [
          {
            '日期': {
              'date_histogram': {
                'field': 'created',
                'interval': '1d',
                'time_zone': '+08:00'
              }
            }
          },
          {
            'current_page': {
              'terms': {
                'field': 'current_page'
              }
            }
          }
        ]
      },
      'aggregations': {
        '(UV)': {
          'cardinality': {
            'field': 'user_id',
            "precision_threshold": 10000,
            "missing": "N/A"
          }
        },
        '(Visitor)': {
          'cardinality': {
            'field': 'session_id',
            "precision_threshold": 10000,
            "missing": "N/A"
          }
        }
      }
    }
  }
}

Looks like you have a time interval of zero length which I assume lead to no matches.

It is gte(>=) and lte(<=) so, I think it is ok. And also, when I only change precision_threshold from 10000 to 100, the result is not zero.

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