def search_types(params, results, meta):
    """
    Convert Elasticsearch results into RPC results conforming to the spec for
    the "search_types" method.
    """
    # Now we need to convert the ES result format into the API format
    search_time = results['search_time']
    buckets = results['aggregations']['type_count']['counts']
    counts_dict = {}  # type: dict
    for count_obj in buckets:
        counts_dict[count_obj['key']] = counts_dict.get(count_obj['key'], 0)
        counts_dict[count_obj['key']] += count_obj['count']
    return {
        'type_to_count': counts_dict,
        'search_time': int(search_time)
    }