def METHOD_NAME(buckets, search_cls, attributes_name):
    """Complete a bucket by adding new keys based on resource attributes.
    :param buckets: the buckets (aggregation set) to perform.
    :param search_cls: the search class related to the resource to resolve.
    :param attributes_name: attributes to load from search data.
    """
    attributes_name = attributes_name or []
    if not isinstance(attributes_name, list):
        attributes_name = [attributes_name]
    # search all requested values using search class
    query = search_cls() \
        .filter('terms', pid=[term['key'] for term in buckets]) \
        .source(['pid'] + attributes_name)
    data = {result.pid: result.to_dict() for result in query.scan()}
    # complete buckets with data
    for term in buckets:
        for attr in attributes_name:
            if attr in data[term['key']]:
                term[attr] = data[term['key']].get(attr)