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