All Products
Search
Document Center

Tablestore:Query documents

Last Updated:Sep 24, 2026

Use the GetDocument operation to query the detailed information of a specified document. The data field in the response is an array of document records, and the response field table describes a single record in the array. When you query by ossKey, deleting and recreating the same file may return multiple results that include historical records. To query the status of the current import, use the docId returned by AddDocuments to locate the record.

Prerequisites

  • An AgentStorage instance is created and its status is normal, and the endpoint and instance name are obtained.

  • An API Key is created.

  • The knowledge base and document to query already exist.

Request parameters

Parameter

Type

Description

knowledgeBaseName

string

The name of the knowledge base. Required.

subspace

string

The subspace name. Required when subspace is enabled.

docId

string

The document ID. Either this or ossKey.

ossKey

string

The OSS file path. Either this or docId.

Request example

When you use API Key authentication, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.

curl -X POST https://<endpoint>/GetDocument \
  -H "x-ots-instancename: <instance-name>" \
  -H "x-ots-apikey: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
  "knowledgeBaseName": "product_docs_kb",
  "subspace": "default",
  "ossKey": "oss://example-bucket/docs/manual.pdf"
}'

Response

Field

Type

Description

docId

string

The document ID.

ossKey

string

The OSS path.

subspace

string

The subspace.

chunkNum

int

The number of chunks.

status

string

The document status: pending/indexing/completed/failed/deleting

createdAt

int

The creation timestamp.

updatedAt

int

The update timestamp.

eTag

string

The document eTag.

failedDetails

string

The failure reason (only when the status is failed).

metadata

object

The document metadata.

{
    "code": "SUCCESS",
    "data": [
        {
            "docId": "fc6ed97f-28ad-4dc0-9b73-bf4a7d67ab65",
            "ossKey": "oss://example-bucket/docs/manual.pdf",
            "subspace": "default",
            "chunkNum": 1,
            "status": "completed",
            "createdAt": 1787636583092,
            "eTag": "6227CEC56ABFAF47135E4C033FF24C98",
            "updatedAt": 1787636583092, "metadata": {"author": "张三", "date": "2026-01-22 10:00:59", "score": 80}
        }
    ],
    "message": "succeed"
}