from typing import Dict
import requests


def read_number_from_es(es_host) -> Dict[str, int]:
    """
    Get numbers of records
    :param es_host: the address where the elastic search is hosted
    :return: numbers of records in all indices found at the given address
    """
    counts = {}
    url = f"{es_host}/_cat/indices?v"
    """
    example of response
    health status index                    uuid                   pri rep docs.count docs.deleted store.size 
    pri.store.size
    green  open   faang_build_2_specimen   bo3YAiLmSUWqlgtzVElzKQ   5   1       9388            0     18.4mb            
    9mb
    green  open   faang_build_4_specimen   _jSFP7MRS6qVrkiqcQ9f4Q   5   1       9388            0       19mb          
    9.6mb
    """
    response = requests.get(url).text
    # removes the header of returned value
    lines = response.split("\n")[1:]
    for line in lines:
        elmts = line.split()
        if elmts:
            # 3rd column is the index name and 7th column is docs.count
            counts[elmts[2]] = elmts[6]

    return counts