Different counts of unique values in Kibana and CSV-export of the raw data

Hello Community!

I am using Kibana v 7.17.9

I count unique values for various log variables (Visualize->Metric->unique count). But the number of unique values differs slightly, depending on whether I use Kibana or export the same database as .csv-file and edit it with another statistics program (R, Python).

Example:

Total hits in Kibana 3567 -> unique count of user_id: 3267

Total count in .csv-file/Python 3567 -> unique count of user_id: 3275

Does anyone know reasons why this is happening?

Thanks a lot!

Mario