(sketch_id, labels)
return label_query
Build OpenSearch query for Timesketch labels.

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

        Returns:
            OpenSearch query as a dictionary.
Build OpenSearch query for Timesketch labels.
Build OpenSearch query for Timesketch labels .
def _build_labels_query(sketch_id, labels):
        """Build OpenSearch query for Timesketch labels.

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

        Returns:
            OpenSearch query as a dictionary.
        """
        label_query = {
            'bool': {
                'must': []
            }
        }

        for label in labels:
            # Increase metrics counter per label
            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
def _build_labels_query ( sketch_id , labels ) : label_query = { 'bool' : { 'must' : [ ] } } for label in labels : # Increase metrics counter per label 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