If one wants to count the number of documents in an index (of Elasticsearch) then there are (at least?) two possibilities:
Direct count
curl http://localhost:9200/_cat/indices?v
provides you the count and other information in a tabular format
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open logstash-2019.10.09-000001 IS7HBUgRRzO7Rn1puBFUIQ 1 1 0 0 283b 283b
green open .kibana_task_manager_1 e4zZcF9wSQGFHB_lzTszrg 1 0 2 0 12.5kb 12.5kb
yellow open metricbeat-7.4.0-2019.10.09-000001 h_CWzZHcRsakxgyC36-HTg 1 1 6118 0 2.2mb 2.2mb
green open .apm-agent-configuration J6wkUr2CQAC5kF8-eX30jw 1 0 0 0 283b 283b
green open .kibana_2 W2ZETPygS8a83-Xcd6t44Q 1 0 1836 23 1.1mb 1.1mb
green open .kibana_1 IrBlKqO0Swa6_HnVRYEwkQ 1 0 8 0 208.8kb 208.8kb
yellow open filebeat-7.4.0-2019.10.09-000001 xSd2JdwVR1C9Ahz2SQV9NA 1 1 0 0 283b 283b
green open .tasks 0ZzzrOq0RguMhyIbYH_JKw 1 0 1 0 6.3kb 6.3kb