:doc:`IoT <../../iot>` / Client / get_buckets_aggregation

***********************
get_buckets_aggregation
***********************



.. py:method:: IoT.Client.get_buckets_aggregation(**kwargs)

  

  Aggregates on indexed data with search queries pertaining to particular fields.

   

  Requires permission to access the `GetBucketsAggregation <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions>`__ action.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iot-2015-05-28/GetBucketsAggregation>`_  


  **Request Syntax**
  ::

    response = client.get_buckets_aggregation(
        indexName='string',
        queryString='string',
        aggregationField='string',
        queryVersion='string',
        bucketsAggregationType={
            'termsAggregation': {
                'maxBuckets': 123
            }
        }
    )
    
  :type indexName: string
  :param indexName: 

    The name of the index to search.

    

  
  :type queryString: string
  :param queryString: **[REQUIRED]** 

    The search query string.

    

  
  :type aggregationField: string
  :param aggregationField: **[REQUIRED]** 

    The aggregation field.

    

  
  :type queryVersion: string
  :param queryVersion: 

    The version of the query.

    

  
  :type bucketsAggregationType: dict
  :param bucketsAggregationType: **[REQUIRED]** 

    The basic control of the response shape and the bucket aggregation type to perform.

    

  
    - **termsAggregation** *(dict) --* 

      Performs an aggregation that will return a list of buckets. The list of buckets is a ranked list of the number of occurrences of an aggregation field value.

      

    
      - **maxBuckets** *(integer) --* 

        The number of buckets to return in the response. Default to 10.

        

      
    
  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'totalCount': 123,
          'buckets': [
              {
                  'keyValue': 'string',
                  'count': 123
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **totalCount** *(integer) --* 

        The total number of things that fit the query string criteria.

        
      

      - **buckets** *(list) --* 

        The main part of the response with a list of buckets. Each bucket contains a ``keyValue`` and a ``count``.

         

        ``keyValue``: The aggregation field value counted for the particular bucket.

         

        ``count``: The number of documents that have that value.

        
        

        - *(dict) --* 

          A count of documents that meets a specific aggregation criteria.

          
          

          - **keyValue** *(string) --* 

            The value counted for the particular bucket.

            
          

          - **count** *(integer) --* 

            The number of documents that have the value counted for the particular bucket.

            
      
    
  
  **Exceptions**
  
  *   :py:class:`IoT.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`IoT.Client.exceptions.ThrottlingException`

  
  *   :py:class:`IoT.Client.exceptions.UnauthorizedException`

  
  *   :py:class:`IoT.Client.exceptions.ServiceUnavailableException`

  
  *   :py:class:`IoT.Client.exceptions.InternalFailureException`

  
  *   :py:class:`IoT.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`IoT.Client.exceptions.InvalidQueryException`

  
  *   :py:class:`IoT.Client.exceptions.InvalidAggregationException`

  
  *   :py:class:`IoT.Client.exceptions.IndexNotReadyException`

  