文档与分段
重新索引文档
为每个选中的文档排入一个索引任务,根据其当前文件重建索引。返回一个批量任务 ID,用于统一跟踪这些任务。
all: true 和 documentIds 必须且只能提供其中一个。
不会重新上传任何文件。用 compilation_job.id 通过 获取索引任务 跟踪单个任务,通过 获取批量任务 跟踪整个请求。
重新索引流程详见 重新索引并跟踪索引进度。
POST
/
knowledge-fs
/
spaces
/
{knowledge_base_id}
/
documents
/
reindex
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/documents/reindex \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"all": true
}'{
"bulk_job_id": "5a1c2e3d-7b8f-4a9c-8d1e-2f3a4b5c6d7e",
"items": [
{
"asset": {
"created_at": "2026-09-03T10:02:11Z",
"filename": "handbook.pdf",
"id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"metadata": {},
"mime_type": "application/pdf",
"object_key": "1a7c9e40-2b3d-4f56-8a90-b1c2d3e4f506/spaces/9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b/documents/6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b/handbook.pdf",
"parser_status": "parsed",
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"size_bytes": 482113,
"source_id": null,
"updated_at": null,
"version": 1
},
"code": null,
"compilation_job": {
"id": "e4a1f0b2-7c3d-4e5f-9a1b-2c3d4e5f6a7b",
"stage": "queued"
},
"document_id": null,
"error": null,
"status": "queued",
"status_url": "/knowledge-spaces/9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b/documents/3d2f1c0b-9a8e-4d7c-b6a5-4f3e2d1c0b9a/processing-tasks/e4a1f0b2-7c3d-4e5f-9a1b-2c3d4e5f6a7b"
},
{
"asset": null,
"code": null,
"compilation_job": null,
"document_id": "8f14e45f-ceea-467a-9575-62c9a2d3e6b1",
"error": null,
"status": "not_found",
"status_url": null
}
],
"total": 2
}Authorizations
Headers
每次调用都应发送幂等键,这样重试才安全。使用 8~255 个可打印 ASCII 字符,首尾不得有空白;格式不正确的键返回 400。
重复发送相同的键和请求体,会返回原批量任务,不会启动新的索引任务。以不同的请求体、通过其他 API 密钥、在其他知识库中或为其他操作复用该键,会返回 409。
Required string length:
8 - 255Path Parameters
知识库 ID:即知识库 API 访问 对话框中所示服务 API 端点的最后一段(…/knowledge-fs/spaces/<knowledge base ID>),也是地址栏中 /datasets/new/ 之后的那一段。
Body
application/json
标记为 nullable 的可选字段,传 null 等同于省略。
规范化后的请求不得超过 1,048,576 个 UTF-8 字节。参见 请求大小限制。
- 全部文档
- 指定文档
发送 all: true 或非空的 documentIds 数组,二者不可同时发送。使用 documentIds 时,all 可省略,也可为 false 或 null。使用 all: true 时,documentIds 可省略或为 null;空数组会被拒绝。
设为 true 时,重新索引该密钥可读取的所有文档文件。文件数超过上限(默认 100)时,调用返回 400,且不会重新索引任何内容。
Available options:
true Was this page helpful?
⌘I
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/documents/reindex \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"all": true
}'{
"bulk_job_id": "5a1c2e3d-7b8f-4a9c-8d1e-2f3a4b5c6d7e",
"items": [
{
"asset": {
"created_at": "2026-09-03T10:02:11Z",
"filename": "handbook.pdf",
"id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"metadata": {},
"mime_type": "application/pdf",
"object_key": "1a7c9e40-2b3d-4f56-8a90-b1c2d3e4f506/spaces/9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b/documents/6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b/handbook.pdf",
"parser_status": "parsed",
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"size_bytes": 482113,
"source_id": null,
"updated_at": null,
"version": 1
},
"code": null,
"compilation_job": {
"id": "e4a1f0b2-7c3d-4e5f-9a1b-2c3d4e5f6a7b",
"stage": "queued"
},
"document_id": null,
"error": null,
"status": "queued",
"status_url": "/knowledge-spaces/9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b/documents/3d2f1c0b-9a8e-4d7c-b6a5-4f3e2d1c0b9a/processing-tasks/e4a1f0b2-7c3d-4e5f-9a1b-2c3d4e5f6a7b"
},
{
"asset": null,
"code": null,
"compilation_job": null,
"document_id": "8f14e45f-ceea-467a-9575-62c9a2d3e6b1",
"error": null,
"status": "not_found",
"status_url": null
}
],
"total": 2
}