Scripted field & range analysis not working properly?

Hi guys,

happy new year :slight_smile:
I have a scripet field (number, percentage) with this code:

double tot_acc_nom_gruppo = doc['tot_acc_nom_gruppo'].value;
double tot_acc_pond_gruppo = doc['tot_acc_pond_gruppo'].value;
double delta_pratica = 1;
if((tot_acc_nom_gruppo != 0) && (tot_acc_pond_gruppo != 0)){
    delta_pratica = tot_acc_nom_gruppo / tot_acc_pond_gruppo;
}

return delta_pratica;

This painless code produces some results like:
47.345% or 137.238% and this is fine for me.

But if I try to create a table with a filter column in order to see the unique count of my documents for each range (0 - 10%, 10% - 20%, 20% - 30%) the total sum of unique count for each range is greather then the real unique count of my documents.

It's like some document is part of 2 or more range. Could you please help me?

Thanks!
Salvo

Hi @SalvoDM91 ,

Could you share an example of your aggregation? It could be the same document ends in different buckets (data sets) based on your conditions.

Regards, Dima

Ciao Dzmitry, I just found the problem.
I have more then 900K documents in my index and I see inside the documentation that Unique count is an an approximate count of distinct values.

This is a big issue for me... there is any way in Kibana in order to see the exact number?

Thanks in advance
Salvo

I'm afraid with these amount of docs Elasticsearch might not return the exact count, but approximate one. But I would double check with Elasticsearch community by posting question there.

Regards, DIma