Facet Search by Statistics Aggregation
Calculates statistics of attribute values: min,
        max, count, average, and
            sum.
General restrictions
The min, max, average, and
                sum values of aggregation operate on the double
            representation of the data. As a consequence, the result may be approximate when running
            on longs (fields with long type) whose absolute value is greater than
                2^53.
Stats Aggregation
This type of aggregation calculates statistics of the attribute values
                    min, max, count,
                    average, and sum.
| Parameter | Value | Required | Value Type | 
|---|---|---|---|
fieldName | Facet attribute (same as facet in basic facet
                                request) | Yes | String | 
facetType | stats | Yes | ENUM | 
Response Format
The response contains:
| Field | Type | Description | 
|---|---|---|
count | long | Amount of values. | 
min | double | Minimal value; not present if count=0. | 
max | double | Maximum value; not present if count=0. | 
avg | double | Average value; not present if count=0. | 
sum | double | Sum of values; not present if count=0. | 
Example
POST /api/{tenantId}/entities/_facets
                [
                {
                "fieldName": "attributes.height",
                "facetType": "stats"
                }
                ]
            
            
            Response
{
  "attributes.height": {
    "count": 4,
    "min": 100.0,
    "max": 400.0,
    "avg": 202.5,
    "sum": 810.0
  }
}
        Extended Stats Aggregation
The extended_stats aggregation is an extended version of the stats
                aggregation, where additional metrics are added such as the sum of squares, standard
                deviation (SD), variance, and SD bounds. In addition to stats aggregation, this can
                have input parameters. 
By default, the extended_stats metric will return SD bounds, which
                provides an interval of plus/minus two standard deviations from the mean. If you
                want a different boundary, for example, three standard deviations,
                    sigma can be specified as a request parameter.
| Parameter | Value | Required | Value Type | 
|---|---|---|---|
fieldName | Facet attribute (same as facet in basic facet
                                request) | Yes | String | 
facetType | extended_stats | Yes | ENUM | 
sigma | No | double | 
Response Format
The response contains:
| Field | Type | Description | 
|---|---|---|
count | long | Amount of values. | 
min | double | Minimal value; not present if count=0. | 
max | double | Maximum value; not present if count=0. | 
avg | double | Average value; not present if count=0. | 
sum | double | Sum of values; not present if count=0. | 
sum_of_squares | double | Sum of squares; not present if count=0. | 
variance | double | Variance of SD; not present if count=0. | 
std_deviation | double | Standard deviation value; not present if
                                count=0. | 
std_deviation_upper_bound | double | SD upper bound; not present if count=0. | 
std_deviation_lower_bound | double | SD lower bound; not present if count=0. | 
Example
POST /api/{tenantId}/entities/_facets
[
  {
    "fieldName": "attributes.height",
    "facetType": "extended_stats",
    "sigma": 3.0
  }
]
            Response
{
 "attributes.height": {
   "count": 4,
   "min": 100.0,
   "max": 400.0,
   "avg": 202.5,
   "sum": 810.0,
   "sum_of_squares": 222100.0,
   "variance": 14518.75,
   "std_deviation": 120.49377577285891,
   "std_deviation_upper_bound": 443.4875515457178,
   "std_deviation_lower_bound": -38.48755154571782
 }
}
        Min/Max/Sum/Avg/Count Aggregations
This type of aggregation is single value aggregation to find min/max/sum/avg value or amount of values.
| Parameter | Value | Required | Value Type | 
|---|---|---|---|
fieldName | Facet attribute (same as facet in basic facet
                                request) | Yes | String | 
facetType | One of the following: min, max,
                                    sum, avg, or
                                    valueCount | Yes | ENUM | 
Response Format
The response contains:
| Field | Type | Description | 
|---|---|---|
min | double | Minimal value; null if no data has
                                matched. | 
| Field | Type | Description | 
|---|---|---|
max | double | Maximum value; null if no data has
                                matched. | 
| Field | Type | Description | 
|---|---|---|
avg | double | Average value; null if no data has
                                matched. | 
| Field | Type | Description | 
|---|---|---|
sum | double | Sum of values; 0 if no data has matched. | 
| Field | Type | Description | 
|---|---|---|
count | long | Count of values; 0 if no data has
                                matched. | 
Example
POST /api/{tenantId}/entities/_facets
[
  {
    "fieldName": "attributes.height",
    "facetType": "min"
  }
]
            Response
{
  "attributes.height": {
    "min": 100.0
  }
}
            Response (in case no data has matched)
{
  "attributes.height": {}
}