GroupByField groups query results by field value. You can use this aggregation method to group query results based on field values. The values that are the same are grouped together. The identical value of each group and the number of identical values in each group are returned.
Request parameters
message GroupByField {
optional string field_name = 1;
optional int32 size = 2;
optional GroupBySort sort = 3;
optional Aggregations sub_aggs = 4;
optional GroupBys sub_group_bys = 5;
optional int64 min_doc_count = 6;
}
Parameter | Type | Required | Description |
field_name | string | Yes | The field that is used for aggregation. |
size | int32 | Yes | The number of groups that you want to return. Default value: 10. Maximum value: 2000. If the number of groups exceeds 2,000, only the first 2,000 groups are returned. |
sort | 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. | |
sub_aggs | No | The sub-aggregation operation that is performed on the grouping results. | |
sub_group_bys | No | The sub-GroupBy operation that is performed on the grouping results. | |
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. |
Response parameters
message GroupByFieldResult {
repeated GroupByFieldResultItem group_by_field_result_items = 1;
}
Parameter | Type | Required | Description |
group_by_field_result_items | repeated GroupByFieldResultItem | Yes | The information about groups returned. |