def remove_underscore_from_end_prefix(es_index_prefix: str) -> str:
    """
    Remove the last underscore from index prefix if existing
    :param es_index_prefix: the index prefix may having underscore at the end
    :return: the 'cleaned' index prefix
    """
    if es_index_prefix.endswith("_"):
        str_len = len(es_index_prefix)
        es_index_prefix = es_index_prefix[0:str_len - 1]
    return es_index_prefix