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/aggregate

Protocol: 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

ParameterTypeDescription
accessUserNameStringThe username. To view your username, go to Instance Details > API Endpoint.
accessPassWordStringThe 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

ParameterTypeRequiredDefaultDescription
tableNameStringYes-The name of the table to query.
filterStringNo""The filter condition.
groupKeysList[String]No[]The fields to group results by.
aggFuncsList[AggFuncDesc]Yes-The aggregation functions to apply.
orderByList[OrderByDesc]No[]The sort order for results. Supports multi-field sorting.
timeoutIntegerNo10000The request timeout in milliseconds.

AggFuncDesc

ParameterTypeRequiredDefaultDescription
nameStringNo""The field name for the aggregated value in the result set. Defaults to FUNC_NAME(args).
funcStringYes-The aggregation function. Valid values: max, min, avg, sum, count.
argsList[String]Yes-The arguments for the aggregation function.

OrderByDesc

ParameterTypeRequiredDefaultDescription
fieldStringYes-The sort field. Must be a field in the result set.
directionStringNoDESCThe sort direction. Valid values: DESC (descending), ASC (ascending).

Response parameters

ParameterTypeDescription
totalCountIntegerThe number of results in the result set.
coveredPercentFloatThe proportion of shards that returned normal results.
resultList[Map]The aggregated results.
totalTimeFloatThe time taken for the aggregation, in milliseconds.
errorCodeIntegerThe error code. Returned only if the request failed.
errorMsgStringThe 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
}