查看文档详情

查询一个来源文档的当前分段版本、索引版本和分段内容。编辑分段前先用此接口保存当前版本和索引版本。

GET https://api.moi.matrixorigin.cn/v5/semantic-models/{model_id}/sources/{source_row_id}/document

调用前准备

查询数据源列表取得来源记录 ID。准备有目标工作区访问权限的个人访问令牌和目标工作区 ID。

请求参数

curl "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/document?segment_version_id=$SEGMENT_VERSION_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"

字段

类型

必填

说明

model_id

integer

知识库 ID。

source_row_id

string

来源记录 ID。

字段

类型

必填

说明

segment_version_id

string

要读取的分段版本 ID;不传时读取当前版本。

成功响应

成功时返回 200data 返回文档预览、版本列表和所选版本的分段内容。

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "source": {
      "row_id": "src_01",
      "model_id": 401,
      "source_type": "file",
      "ingest_status": "ready"
    },
    "preview": {
      "available": true,
      "content": "产品说明"
    },
    "file_info": {
      "tags": ["product"],
      "enabled": true,
      "effective_enabled": true,
      "index_version": 2,
      "segment_version_id": "ver_02"
    },
    "segment_status": {
      "available": true,
      "total": 1
    },
    "current_segment_version_id": "ver_02",
    "current_index_version": 2,
    "segment_versions": [
      {
        "version_id": "ver_02",
        "current": true,
        "index_version": 2,
        "chunk_count": 1
      }
    ],
    "segments": [
      {
        "segment_id": "seg_01",
        "segment_type": "text",
        "level": "chunk",
        "content": "产品说明",
        "enabled": true
      }
    ]
  }
}

字段

类型

说明

code

string

成功时为 OK

msg

string

成功时为 OK

data

object

响应数据。

下面表格展开响应示例中 data 对象;每一行是该对象的一个字段。

字段

类型

说明

source

object

来源记录,详见“来源记录”。

preview

object

来源内容预览,详见“内容预览”。

file_info

object

文件标签、过期和启用信息,详见“文件与分段状态”。

segment_status

object

当前分段可用状态和数量,详见“文件与分段状态”。

current_segment_version_id

string 或 null

当前分段版本 ID。

current_index_version

integer 或 null

当前索引版本。

selected_segment_version_id

string 或 null

本次返回选择的分段版本 ID。

selected_index_version

integer 或 null

本次返回选择的索引版本。

segment_versions

array of object

所有可用分段版本,详见“分段版本”;来源尚未完成解析或未生成分段版本时可能省略。

segments

array of object

所选版本中的分段,详见“分段内容”。

下面表格展开响应示例中 data.source 对象;每一行是该对象的一个字段。

来源标识

字段

类型

说明

row_id

string

来源记录 ID。

source_id

string 或 null

来源 ID。

source_type

string

来源类型。

model_id

integer

所属知识库 ID。

resource_id

string

来源资源 ID。

source_resource_id

string 或 null

原始资源 ID。

kb_resource_id

string 或 null

知识库侧资源 ID。

source_file_id

string 或 null

原始文件 ID。

kb_file_id

string 或 null

知识库文件 ID。

source_table_id

integer 或 null

原始表 ID。

kb_table_id

integer 或 null

知识库表 ID。

来源位置与规模

字段

类型

说明

display_name

string 或 null

显示名称。

path

array of string

来源路径。

source_path

string 或 null

原始来源路径。

db_name

string 或 null

数据库名称。

table_name

string 或 null

表名称。

size_bytes

integer 或 null

文件大小。

row_count

integer 或 null

表行数。

处理与治理状态

字段

类型

说明

ingest_status

string 或 null

处理状态。

enabled

boolean 或 null

配置的启用状态。

expires_at

integer 或 null

到期时间。

expired

boolean

是否已到期。

effective_enabled

boolean

当前实际生效状态。

force_enabled_after_expiry

boolean

到期后是否强制启用。

tags

array of string

来源标签。

segment_version_id

string 或 null

当前分段版本 ID。

index_version

integer 或 null

当前索引版本。

created_by

string 或 null

创建者 ID。

updated_by

string 或 null

最后更新者 ID。

updated_at

integer 或 null

最近更新时间。

error

string 或 null

处理错误。

governance_status

string

治理状态。

legacy_origin

string 或 null

历史来源标记。

下面表格展开响应示例中 data.preview 对象;每一行是该对象的一个字段。

字段

类型

说明

available

boolean

预览内容是否可用。

content

string 或 null

预览内容。

reason

string 或 null

预览不可用原因。

文件信息

下面表格展开响应示例中 data.file_info 对象;每一行是该对象的一个字段。

字段

类型

说明

tags

array of string

文件标签。

expires_at

integer 或 null

到期时间。

enabled

boolean 或 null

配置的启用状态。

expired

boolean

是否已到期。

effective_enabled

boolean

当前实际生效状态。

force_enabled_after_expiry

boolean

到期后是否强制启用。

index_version

integer 或 null

当前索引版本。

segment_version_id

string 或 null

当前分段版本 ID。

分段状态

下面表格展开响应示例中 data.segment_status 对象;每一行是该对象的一个字段。

字段

类型

说明

available

boolean

分段是否可用。

reason

string 或 null

不可用原因。

total

integer

分段数量。

下面表格展开响应示例中 data.segment_versions 数组的每一项;每一行是该数组项的一个字段。

字段

类型

说明

version_id

string

分段版本 ID。

current

boolean

是否为当前分段版本。

index_version

integer 或 null

索引版本。

base_version_id

string 或 null

基线分段版本 ID。

base_index_version

integer 或 null

基线索引版本。

status

string

版本状态。

source

string

版本来源。

chunk_count

integer

分段总数。

enabled_chunk_count

integer

已启用分段数。

created_by

string 或 null

创建者 ID。

updated_by

string 或 null

最后更新者 ID。

created_at

integer 或 null

创建时间。

updated_at

integer 或 null

最近更新时间。

下面表格展开响应示例中 data.segments 数组的每一项;每一行是该数组项的一个字段。

字段

类型

说明

segment_id

string

分段 ID。

segment_type

string

分段类型。

start_ms

integer 或 null

起始时间或位置。

end_ms

integer 或 null

结束时间或位置。

level

string

分段层级。

chunk_index

integer 或 null

分段序号。

chunk_id

string 或 null

块 ID。

content

string 或 null

分段内容。

ocr_text

string 或 null

OCR 文本。

image_description

string 或 null

图片描述。

image_file_id

string 或 null

图片文件 ID。

page_image_file_id

string 或 null

页图片文件 ID。

word_count

integer

词数。

recall_count

integer

召回次数。

enabled

boolean

分段是否启用。

metadata

object

json.RawMessage 开放键值元数据;服务端不定义固定子字段。

错误响应

{
  "code": "ErrNotFound",
  "msg": "resource not found",
  "data": null
}

字段

类型

说明

code

string

错误代码。

msg

string

面向调用者的错误信息。

data

null

发生错误时为 null

后续操作

需要补充内容时创建分段;修改已有分段时更新分段

最后更新于