hi ,
we trying to use unique count in Elasticsearch
we know its Cardinality Aggregation and give approximate count .
we also tried using "precision_threshold":10000 , but still count is not exact.
let me give info -
index contain total 5000 record for 1 month period
distinct record -4234
have data like this -
outlet-day,swat_code
5102~011~007~00053307-2021-04-25 ,100006
5102~020~001~00053384-2021-04-27 ,100006
5102~020~010~00053292-2021-04-27 ,100006
5102~030~006~00052924-2021-04-29 ,100014
5102~040~003~00053106-2021-04-27 ,100006
5102~040~006~00218477-2021-04-28 ,100006
5102~040~013~00053208-2021-04-29 ,100006
5102~050~009~00218320-2021-04-28 ,100014
5103~010~001~01019629-2021-04-25 ,100007
5103~010~001~01029465-2021-04-25 ,100013
5103~040~013~01141795-2021-04-27 ,100005
5104~010~005~01025316-2021-04-26 ,100015
5104~020~007~00047242-2021-04-27 ,100015
5104~020~007~00647900-2021-04-27 ,100015
5104~030~009~00047794-2021-04-25 ,100015
5105~020~004~01141214-2021-04-29 ,100002
5105~030~008~00059677-2021-04-29 ,100002
5105~030~010~00060227-2021-04-29 ,100002
5105~040~006~00960571-2021-04-29 ,100002
5106~020~005~00929656-2021-04-29 ,100015
5106~030~006~00059961-2021-04-29 ,100015
5107~010~003~00218474-2021-04-26 ,100002
5107~040~005~00457483-2021-04-25 ,100002
my first query -
{
"aggs": {
"1": {
"cardinality": {
"field": "outlet-day.keyword",
"precision_threshold": 10000
}
}
},
even after precision is not give exact count .
my other query for same date range -
i added extra term aggregation -
{
"aggs": {
"2": {
"terms": {
"field": "swat_code.keyword",
"order": {
"1": "desc"
},
"size": 5
},
"aggs": {
"1": {
"cardinality": {
"field": "outlet-day.keyword"
}
}
}
}
}
this give current count even without precision_threshold.
but for matric visual , how we can get exact count .
Please let us know if there is any other way .
Thanks in advance .
Dilip