(
            self, field, limit=10, supported_charts='table',
            start_time='', end_time='', order_field='count')
return interface.AggregationResult(
            encoding=encoding, values=values, chart_type=supported_charts,
            sketch_url=self._sketch_url, field=field)
Run the aggregation.

        Args:
            field: What field to aggregate on.
            limit: How many buckets to return.
            supported_charts: Chart type to render. Defaults to table.
            start_time: Optional ISO formatted date string that limits the time
                range for the aggregation.
            end_time: Optional ISO formatted date string that limits the time
                range for the aggregation.
            order_field: The name of the field that is used for the order
                of items in the aggregation, defaults to "count".

        Returns:
            Instance of interface.AggregationResult with aggregation result.
Run the aggregation.
Run the aggregation .
def run(
            self, field, limit=10, supported_charts='table',
            start_time='', end_time='', order_field='count'):
        """Run the aggregation.

        Args:
            field: What field to aggregate on.
            limit: How many buckets to return.
            supported_charts: Chart type to render. Defaults to table.
            start_time: Optional ISO formatted date string that limits the time
                range for the aggregation.
            end_time: Optional ISO formatted date string that limits the time
                range for the aggregation.
            order_field: The name of the field that is used for the order
                of items in the aggregation, defaults to "count".

        Returns:
            Instance of interface.AggregationResult with aggregation result.
        """
        self.field = field
        formatted_field_name = self.format_field_by_type(field)

        # Encoding information for Vega-Lite.
        encoding = {
            'x': {
                'field': field,
                'type': 'nominal',
                'sort': {
                    'op': 'sum',
                    'field': order_field,
                    'order': 'descending'
                }
            },
            'y': {'field': 'count', 'type': 'quantitative'},
            'tooltip': [
                {'field': field, 'type': 'nominal'},
                {'field': order_field, 'type': 'quantitative'}],
        }

        aggregation_spec = {
            'aggs': {
                'aggregation': {
                    'terms': {
                        'field': formatted_field_name,
                        'size': limit
                    }
                }
            }
        }

        aggregation_spec = self._add_query_to_aggregation_spec(
            aggregation_spec, start_time, end_time)

        response = self.opensearch_aggregation(aggregation_spec)
        aggregations = response.get('aggregations', {})
        aggregation = aggregations.get('aggregation', {})

        buckets = aggregation.get('buckets', [])
        values = []
        for bucket in buckets:
            d = {field: bucket['key'], 'count': bucket['doc_count']}
            values.append(d)

        return interface.AggregationResult(
            encoding=encoding, values=values, chart_type=supported_charts,
            sketch_url=self._sketch_url, field=field)
def run ( self , field , limit = 10 , supported_charts = 'table' , start_time = '' , end_time = '' , order_field = 'count' ) : self . field = field formatted_field_name = self . format_field_by_type ( field ) # Encoding information for Vega-Lite. encoding = { 'x' : { 'field' : field , 'type' : 'nominal' , 'sort' : { 'op' : 'sum' , 'field' : order_field , 'order' : 'descending' } } , 'y' : { 'field' : 'count' , 'type' : 'quantitative' } , 'tooltip' : [ { 'field' : field , 'type' : 'nominal' } , { 'field' : order_field , 'type' : 'quantitative' } ] , } aggregation_spec = { 'aggs' : { 'aggregation' : { 'terms' : { 'field' : formatted_field_name , 'size' : limit } } } } aggregation_spec = self . _add_query_to_aggregation_spec ( aggregation_spec , start_time , end_time ) response = self . opensearch_aggregation ( aggregation_spec ) aggregations = response . get ( 'aggregations' , { } ) aggregation = aggregations . get ( 'aggregation' , { } ) buckets = aggregation . get ( 'buckets' , [ ] ) values = [ ] for bucket in buckets : d = { field : bucket [ 'key' ] , 'count' : bucket [ 'doc_count' ] } values . append ( d ) return interface . AggregationResult ( encoding = encoding , values = values , chart_type = supported_charts , sketch_url = self . _sketch_url , field = field )