All Products
Search
Document Center

Tablestore:GroupByHistogram

Last Updated:May 10, 2024

GroupByHistogram specifies the group by histogram feature. You can use this feature to group query results based on specific data intervals. Field values that are within the same range are grouped together. The value range of each group and the number of values in each group are returned.

Request parameters

message GroupByHistogram {
    optional string field_name = 1;
    optional bytes interval = 2;
    optional bytes missing = 3;
    optional int64  min_doc_count = 4;
    optional GroupBySort sort = 5;
    optional FieldRange field_range = 6;
    optional Aggregations sub_aggs = 7;
    optional GroupBys sub_group_bys = 8;
}

Parameter

Type

Required

Description

field_name

string

Yes

The field that is used for aggregation.

interval

bytes

Yes

The statistical interval. The value must be encoded in PlainBuffer. For more information, see PlainBuffer.

missing

bytes

No

The default value of a field if the value of the field is empty in the row. The value must be encoded in PlainBuffer. For more information, see PlainBuffer.

  • If you do not specify a value for the missing parameter, the row is ignored.

  • If you specify a value for the missing parameter, the value of this parameter is used as the field value of the row.

min_doc_count

int64

No

The minimum number of rows. If the number of rows in a group is less than the minimum number of rows, the aggregation results for the group are not returned.

sort

GroupBySort

No

The sorting rules for items in a group. By default, group items are sorted in descending order. If you configure multiple sorting rules, data is sorted based on the order in which the rules are configured.

field_range

FieldRange

Yes

The range that is used together with the interval parameter to limit the number of groups. The value that is calculated by using the (field_range.max-field_range.min)/interval formula cannot exceed 2,000.

sub_aggs

Aggregations

No

The sub-aggregation operation. You can perform the sub-aggregation operation on the grouping results.

sub_group_bys

GroupBys

No

The sub-GroupBy operation. You can perform the sub-GroupBy operation on the grouping results.

Response parameters

message GroupByHistogramResult {
    repeated GroupByHistogramItem group_by_histogra_items = 1;
}

Parameter

Type

Required

Description

group_by_histogra_items

repeated GroupByHistogramItem

Yes

The information about groups returned.