Cluster Aggregate

How to run a cluster aggregate

Open In ColabOpen In Colab

It is often important to figure out the characteristics of each cluster. The best way to do this is through an aggregation query that summarises different fields within the cluster.

This can only can be used after a vector field has been clustered.

What you will need

You will need to have followed the quickstart clustering guide.
You will also need to have knowledge of aggregations.

Code Example

Open In ColabOpen In Colab

The following code example finds the average retail price, maximum retail price and total retail price of each cluster.

DATASET_ID = "quickstart_clustering"
VECTOR_FIELD = "product_name_default_vector_"

# Aggregate based on the eclusters
      {"name": "average_retail_price", "field": "retail_price", "agg": "avg"},
      {"name": "max_retail_price", "field": "retail_price", "agg": "max"},
      {'name':'total_price','field':"retail_price", 'agg':'sum'},

Did this page help you?