Export semantic entries¶
Export knowledge base definitions and semantic entries for review or migration.
GET https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/export
Preparation before calling¶
First query the knowledge base list to obtain the knowledge base 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: The knowledge base ID of the definition to be exported.
Request example¶
curl "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/export" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters¶
Parameters |
Type |
Description |
|---|---|---|
|
integer |
The knowledge base ID of the definition to be exported. |
Successful response¶
Returns 200 on success. Before migrating, export the current state and confirm that the import target has no semantic entries.
{
"code": "OK",
"msg": "OK",
"data": {
"model": {
"id": 401,
"name": "product_docs",
"source_counts": {
"files": 2,
"tables": 1,
"total": 3
}
},
"entries": [
{
"id": 501,
"kind": "metric",
"key": "total_rows",
"tables": ["orders"],
"spec": {
"expr": "COUNT(*)"
}
}
]
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Knowledge base definition. |
|
integer |
Knowledge base ID. |
|
string |
Knowledge base name. |
|
object |
Source quantity statistics. |
|
object[] |
The semantic entry in the current knowledge base. |
|
integer |
Entry ID. |
|
string |
Entry type. |
|
string |
Stable reference key. |
|
array[string] |
Association table name; may be omitted if not set. |
|
object |
Type-specific configuration object corresponding to |
In field paths, [] means each item in an array. For example, data.entries[].id is the id field of each item in data.entries.
Error response¶
{
"code": "ErrNotFound",
"msg": "resource not found",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Use the knowledge base ID from the response. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have read permission. |
Check workspace and object authorization. |
|
|
The knowledge base does not exist or is not visible. |
Reconfirm |
|
|
The service failed to export the definition. |
Keep the desensitized response information and try again. |
Follow-up operations¶
Before migrating or batch writing, use the export results to compare the target knowledge base without semantic entries, and then Import semantic entries.