def elastic_search(dict_distances, query, sequence, tq=None, ts=None, weight=None):
    """
    Query search for elastic measures

    Parameters
    ----------
    dict_distances: dict
        Configuration file with distances
    query: nd-array
        Query time series.
    sequence: nd-array
        Sequence time series.
    tq: nd-array
        Time stamp time series query.
    ts: nd-array
        Time stamp time series sequence.
    weight: nd-array (Default: None)
        query weight values

    Returns
    -------
    distance: nd-array
        distance value between query and sequence
    ac: nd-array
        accumulated cost matrix
    """

    exec("from tssearch import *")

    # distance function
    func_total = dict_distances["function"]

    # Check for parameters
    parameters_total = {}
    if dict_distances["parameters"] != "":
        parameters_total = dict_distances["parameters"]
    parameters_total["report"] = "search"

    if "dtw_type" in parameters_total:
        if parameters_total["dtw_type"] == "dtw":
            parameters_total["dtw_type"] = "sub-dtw"

    if "time" in parameters_total:
        parameters_total_copy = parameters_total.copy()
        del parameters_total_copy["time"]
        distances, ac = locals()[func_total](query, sequence, tq, ts, **parameters_total_copy)
    else:
        distances, ac = locals()[func_total](query, sequence, **parameters_total)

    return distances, ac