Vector engine statistics syntax
Updated at:
Runs aggregation queries against a vector engine table, returning grouped statistics such as max, min, average, sum, and count values.
Endpoint
POST /vector-service/aggregateProtocol: HTTP Format: JSON
Note: The endpoint above omits the host and request header details. To get the host for your application, go to Instance Details > API Endpoint.
Authentication
Use HTTP Basic authentication. Encode your credentials as username:password in Base64, then pass the result in the authorization request header.
Credential parameters
| Parameter | Type | Description |
|---|---|---|
| accessUserName | String | The username. To view your username, go to Instance Details > API Endpoint. |
| accessPassWord | String | The password. To change your password, go to Instance Details > API Endpoint. |
Generate the authorization value
import com.aliyun.darabonba.encode.Encoder;
import com.aliyun.darabonbastring.Client;
public class GenerateAuthorization {
public static void main(String[] args) throws Exception {
String accessUserName = "username";
String accessPassWord = "password";
String realmStr = "" + accessUserName + ":" + accessPassWord + "";
String authorization = Encoder.base64EncodeToString(Client.toBytes(realmStr, "UTF-8"));
System.out.println(authorization);
}
}The output is your Base64-encoded authorization value:
cm9vdDp******mdhbA==Add the Basic prefix when setting the request header:
authorization: Basic cm9vdDp******mdhbA==Request body
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| tableName | String | Yes | - | The name of the table to query. |
| filter | String | No | "" | The filter condition. |
| groupKeys | List[String] | No | [] | The fields to group results by. |
| aggFuncs | List[AggFuncDesc] | Yes | - | The aggregation functions to apply. |
| orderBy | List[OrderByDesc] | No | [] | The sort order for results. Supports multi-field sorting. |
| timeout | Integer | No | 10000 | The request timeout in milliseconds. |
AggFuncDesc
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| name | String | No | "" | The field name for the aggregated value in the result set. Defaults to FUNC_NAME(args). |
| func | String | Yes | - | The aggregation function. Valid values: max, min, avg, sum, count. |
| args | List[String] | Yes | - | The arguments for the aggregation function. |
OrderByDesc
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| field | String | Yes | - | The sort field. Must be a field in the result set. |
| direction | String | No | DESC | The sort direction. Valid values: DESC (descending), ASC (ascending). |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| totalCount | Integer | The number of results in the result set. |
| coveredPercent | Float | The proportion of shards that returned normal results. |
| result | List[Map] | The aggregated results. |
| totalTime | Float | The time taken for the aggregation, in milliseconds. |
| errorCode | Integer | The error code. Returned only if the request failed. |
| errorMsg | String | The error message. Returned only if the request failed. |
Examples
The following example runs a max aggregation on the count field in the test1 table.
Request
{
"aggFuncs": [
{
"args": ["count"],
"func": "max"
}
],
"tableName": "test1"
}Response
{
"totalCount": 1,
"result": [
{
"MAX(count)": 66
}
],
"totalTime": 3.286,
"coveredPercent": 1.0
}Is this page helpful?