List Chunks
Updated at:
Paginate through the chunks in a Knowledge Base.
Prerequisites
Configure the endpoint and authentication first. See API overview and Authentication.
Endpoint
POST /api/v1/indices/rag/index/chunklist
Paginate through the chunks in a specified knowledge base. In the response, data.nodes is the chunk array and data.total is the total chunk count.
NotedocId filters chunks by document. Required for document-search and audio/video-search knowledge bases; not needed for data-query or image-QA knowledge bases.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
indexId | Yes | string | Knowledge base ID, the data.pipelineId returned by the createIndex API. |
pageNum | No | integer | Page number, starting from 1. Default: 1. |
pageSize | No | integer | Number of chunks returned per page. Default: 20. Maximum: 100. |
docId | No | string | Filter by document ID, returning only the chunks under that document. Document IDs can be obtained from the List Documents API. |
Request example
curl -X POST "$BASE_URL/api/v1/indices/rag/index/chunklist" \
-H "Authorization: Bearer $BAILIAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"indexId": "your_index_id",
"pageNum": 1,
"pageSize": 10
}'
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com ({workspace_id} is the workspace ID), and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.
Response example
Returns 200 on success.
{
"code": "Success",
"status_code": 200,
"data": {
"total": 106,
"nodes": [
{
"score": 0.0,
"text": "This is an example of chunk text...",
"metadata": {
"_id": "llm-xxxxxxxxxxxx_your_kb_id_file_xxxxxxxx_0_0",
"doc_id": "file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
"doc_name": "sample_document",
"title": "Product overview",
"content": "This is an example of chunk text...",
"hier_title": "Product overview|Feature introduction",
"doc_url": "https://oss-example.aliyuncs.com/...",
"file_path": "https://oss-example.aliyuncs.com/.../docJson/sample.json",
"image_url": [],
"_chunk_id": 0,
"_block_id": 0,
"pipeline_id": "your_kb_id",
"workspace_id": "llm-xxxxxxxxxxxx",
"_chunk_status": 0,
"_chunk_status_message": "Success",
"is_displayed_chunk_content": true
}
}
],
"isDowngrade": false
},
"success": true,
"message": "success",
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"status": "SUCCESS"
}
Response fields
| Field | Type | Description |
|---|---|---|
code | string | Response code. Success on success. |
status_code | integer | HTTP status code. |
data | object | Business data. Sub-fields: total (integer, total chunk count), nodes (array<object>, chunk node list. Element fields: score (number, relevance score, usually 0 for list queries), text (string, chunk text content), metadata (object, chunk metadata. Sub-fields: _id (string, globally unique chunk identifier), doc_id (string, ID of the document the chunk belongs to), doc_name (string, name of the document), title (string, chunk title), hier_title (string, hierarchical title — the title path separated by |), content (string, chunk content), doc_url (string, original document access URL), file_path (string, OSS path of the chunk parsing output), image_url (array<string>, image URLs associated with the chunk), _chunk_id (integer, chunk sequence number within the document), _block_id (integer, block sequence number), pipeline_id (string, ID of the knowledge base), workspace_id (string, ID of the workspace), _chunk_status (integer, chunk processing status code; 0 indicates success), _chunk_status_message (string, chunk processing status description), is_displayed_chunk_content (boolean, whether the chunk participates in knowledge base retrieval), nid (string, unique chunk number in the knowledge base), source (integer, chunk source type))), isDowngrade (boolean, whether retrieval downgrade occurred). |
success | boolean | Whether the request succeeded. |
message | string | Response message. |
request_id | string | Unique request identifier. Provide this ID when troubleshooting. |
status | string | Request status. SUCCESS on success. |
Is this page helpful?