@staticmethod
def _build_labels_query(sketch_id, labels):
    'Build Elasticsearch query for Timesketch labels.\n\n        Args:\n            sketch_id: Integer of sketch primary key.\n            labels: List of label names.\n\n        Returns:\n            Elasticsearch query as a dictionary.\n        '
    label_query = {'bool': {'must': []}}
    for label in labels:
        METRICS['search_filter_label'].labels(label=label).inc()
        nested_query = {'nested': {'query': {'bool': {'must': [{'term': {'timesketch_label.name.keyword': label}}, {'term': {'timesketch_label.sketch_id': sketch_id}}]}}, 'path': 'timesketch_label'}}
        label_query['bool']['must'].append(nested_query)
    return label_query
Build Elasticsearch query for Timesketch labels.

Args:
    sketch_id: Integer of sketch primary key.
    labels: List of label names.

Returns:
    Elasticsearch query as a dictionary.
@staticmethod
def _build_labels_query(sketch_id, labels):
    'Build Elasticsearch query for Timesketch labels.\n\n        Args:\n            sketch_id: Integer of sketch primary key.\n            labels: List of label names.\n\n        Returns:\n            Elasticsearch query as a dictionary.\n        '
    label_query = {'bool': {'must': []}}
    for label in labels:
        METRICS['search_filter_label'].labels(label=label).inc()
        nested_query = {'nested': {'query': {'bool': {'must': [{'term': {'timesketch_label.name.keyword': label}}, {'term': {'timesketch_label.sketch_id': sketch_id}}]}}, 'path': 'timesketch_label'}}
        label_query['bool']['must'].append(nested_query)
    return label_query