Query document details¶
Read the current snapshot and segments of a source document. Before editing segments, read data.etag as the precondition for a write.
GET https://api.moi.matrixorigin.cn/v5/semantic-models/{model_id}/sources/{source_row_id}/document
Preparation before calling¶
First query the data source list to obtain the source record ID. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$MODEL_ID: Knowledge Base ID.$SOURCE_ROW_ID: Source record ID.
Request example¶
curl "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/document?page_size=20" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters¶
Parameters |
Type |
Description |
|---|---|---|
|
integer |
Knowledge base ID. |
|
string |
Source record ID. |
Query parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
No |
Segments per page. Must be positive; defaults to 20 and is capped at 100. |
|
string |
No |
|
Successful response¶
Returns 200 with the current source, preview, segment status, and this page of segments. The response example is an excerpt.
When data.segment_status.next_cursor is nonempty, pass it as cursor to fetch the next page. Stop when the field is absent or empty. Do not decode or modify the cursor.
curl --get "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/document" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
--data-urlencode "page_size=20" \
--data-urlencode "cursor=$NEXT_CURSOR"
{
"code": "OK",
"msg": "OK",
"data": {
"source": {
"row_id": "src_01",
"model_id": 401,
"source_type": "file",
"ingest_status": "ready"
},
"preview": {
"available": true
},
"file_info": {
"tags": ["product"],
"enabled": true,
"expires_at": null,
"expired": false,
"effective_enabled": true,
"force_enabled_after_expiry": false
},
"segment_status": {
"available": true,
"total": 1
},
"etag": "<DOCUMENT_ETAG>",
"segments": [
{
"segment_id": "seg_01",
"level": "chunk",
"content": "产品说明",
"word_count": 4,
"recall_count": 0,
"enabled": true
}
]
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Source record. |
|
string |
Source ID, returned when nonempty. |
|
string |
Original resource ID, returned when available. |
|
string |
Knowledge-base resource ID, returned when available. |
|
string |
Original file ID, returned when available. |
|
string |
Knowledge-base file ID, returned when available. |
|
integer |
Original table ID, returned when available. |
|
integer |
Knowledge-base table ID, returned when available. |
|
string |
Original source path, returned when available. |
|
array of string |
Source tags, returned when nonempty. |
|
string |
Creator ID, returned when available. |
|
string |
Last updater ID, returned when available. |
|
string |
Governance status, returned when nonempty. |
|
string |
Legacy source marker, returned when available. |
|
boolean |
Whether preview content is available. |
|
string |
Preview content when available. |
|
string |
Reason the preview is unavailable, when applicable. |
|
object |
File tags, expiration and activation information. |
|
array of string or null |
File tags; |
|
integer or null |
File expiration timestamp, or |
|
boolean or null |
Explicit activation setting, or |
|
boolean |
Whether the file has expired. |
|
boolean |
Current actual effective status. |
|
boolean |
Whether activation is forced after expiration. |
|
boolean |
Whether segments are available. |
|
integer |
Number of segments. |
|
string |
Next-page cursor, returned when more segments are available. |
|
string |
Current snapshot precondition; returned when available. Pass it as |
|
array of object |
This page of segments in the current snapshot. |
|
string |
Segment ID. |
|
integer |
Start time or position, returned when available. |
|
integer |
End time or position, returned when available. |
|
string |
Segment level. |
|
integer |
Segment index, returned when available. |
|
string |
Chunk ID, returned when available. |
|
string |
Segment content, returned when available. |
|
string |
OCR text, returned when available. |
|
string |
Image description, returned when available. |
|
string |
Image file ID, returned when available. |
|
string |
Page image file ID, returned when available. |
|
integer |
Unicode character count of joined content, OCR text and image description, including separating newlines. |
|
integer |
Recall count. |
|
boolean |
Whether the segment is enabled. |
|
object |
Source volume metadata, returned when |
In field paths, [] means each item in an array. For example, data.segments[].segment_id is the segment_id field of each item in data.segments.
Error response¶
{
"code": "ErrNotFound",
"msg": "Not Found"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Get the path ID from the source list. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have permission to read the source document. |
Check workspace and object authorization. |
|
|
The knowledge base or source does not exist or is not visible to the current caller. |
Reconfirm the path ID. |
|
|
The service failed to read the document or segment. |
Keep the desensitized response information and try again. |
Follow-up operations¶
To add content, create a segment; to edit an existing segment, update it. Pass data.etag as if_match in the write body or as the If-Match header. After a successful write, use the new snapshot’s ETag. On a precondition conflict, read the document again and review the intended change before submitting it.