Primary key-based query

更新时间:
复制 MD 格式

URL

/vector-service/fetch

  • The URL does not include request headers or encoding details.

  • The URL does not include the host address of the application.

  • For more information about the query parameters in the preceding URL, see the Query Parameters section below.

Request Protocol

HTTP

Request method

POST

Supported format

JSON

Request signature

You can use the following method to calculate the request signature. The request signature is stored in the authorization header.

Parameter

Type

Description

accessUserName

string

You can find the username under Instance Details page > Network Information.

accessPassWord

string

You can modify the password on the Instance Details page in the Network Information section.

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);
 }
}

Valid format for the value of the authorization header:

cm9vdDp******mdhbA==

When you set the authorization header in an HTTP request, add the `Basic ` prefix.

Example: Adding a header

authorization: Basic cm9vdDp******mdhbA==

Request body syntax

Parameter

Description

Type

Required

tableName

The table name.

string

Yes

ids

List of IDs

list[string]

Yes

Example of querying data of the specified primary key field:

{
    "tableName": "gist",
    "ids": [
        "1",
        "2",
        "3"
    ]
}

Response parameters

Field name

Description

Type

result

The returned results.

list[Doc]

totalCount

The number of results.

int

totalTime

The response time. Unit: milliseconds.

float

errorCode

The error code returned if the request failed.

int

errorMsg

The error message returned if the request failed.

string

Definition of a document

Field Name

Description

Type

id

The primary key field.

The data type is specified when you create the table.

vector

The vector field.

list[float]

fields

The attribute field of a vector.

map<string, FieldType>

Example:

{
    "result": [
        {
            "id": "1",
            "vector": [
                0.1,
                0.2,
                0.3
            ],
            "fields": {
                "a": 11
            }
        }
    ],
    "totalCount": 1,
    "totalTime": 1.2
}