def get_filter_labels(self, sketch_id, indices):
    'Aggregate labels for a sketch.\n\n        Args:\n            sketch_id: The Sketch ID\n            indices: List of indices to aggregate on\n\n        Returns:\n            List with label names.\n        '
    max_labels = 10000
    aggregation = {'aggs': {'nested': {'nested': {'path': 'timesketch_label'}, 'aggs': {'inner': {'filter': {'bool': {'must': [{'term': {'timesketch_label.sketch_id': sketch_id}}]}}, 'aggs': {'labels': {'terms': {'size': max_labels, 'field': 'timesketch_label.name.keyword'}}}}}}}}
    labels = []
    try:
        result = self.client.search(index=indices, body=aggregation, size=0)
    except NotFoundError:
        es_logger.error('Unable to find the index/indices: {0:s}'.format(','.join(indices)))
        return labels
    buckets = result.get('aggregations', {}).get('nested', {}).get('inner', {}).get('labels', {}).get('buckets', [])
    for bucket in buckets:
        if bucket['key'].startswith('__'):
            continue
        labels.append(bucket['key'])
    return labels
Aggregate labels for a sketch.

Args:
    sketch_id: The Sketch ID
    indices: List of indices to aggregate on

Returns:
    List with label names.
def get_filter_labels(self, sketch_id, indices):
    'Aggregate labels for a sketch.\n\n        Args:\n            sketch_id: The Sketch ID\n            indices: List of indices to aggregate on\n\n        Returns:\n            List with label names.\n        '
    max_labels = 10000
    aggregation = {'aggs': {'nested': {'nested': {'path': 'timesketch_label'}, 'aggs': {'inner': {'filter': {'bool': {'must': [{'term': {'timesketch_label.sketch_id': sketch_id}}]}}, 'aggs': {'labels': {'terms': {'size': max_labels, 'field': 'timesketch_label.name.keyword'}}}}}}}}
    labels = []
    try:
        result = self.client.search(index=indices, body=aggregation, size=0)
    except NotFoundError:
        es_logger.error('Unable to find the index/indices: {0:s}'.format(','.join(indices)))
        return labels
    buckets = result.get('aggregations', {}).get('nested', {}).get('inner', {}).get('labels', {}).get('buckets', [])
    for bucket in buckets:
        if bucket['key'].startswith('__'):
            continue
        labels.append(bucket['key'])
    return labels