Preview the data source to be added¶
Preview the number of deduplicated files and tables before selecting a source by database or volume. Confirm the quantity before adding the source.
POST https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/source-selections/preview
Preparation before calling¶
First confirm the identification of the database, volume, and its tables and files to be selected in the Catalog. 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 for source selection to be previewed.$DATABASE_ID: Catalog database ID to preview.$TABLE_ID: Table ID in the database to be explicitly selected.
This API previews Catalog data only.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/source-selections/preview" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"source_selections": [
{
"kind": "database_tables",
"database_id": '"$DATABASE_ID"',
"all_selected": false,
"selected_table_ids": ['"$TABLE_ID"']
}
]
}'
Path parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
The knowledge base ID to preview the source selection. |
Request body¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object[] |
Yes |
Source selection to preview. |
|
string |
Yes |
|
|
integer |
Conditionally required |
Catalog Database ID of |
|
integer |
Conditionally required |
Catalog Volume ID of |
|
boolean |
Yes |
|
|
array |
Conditionally required |
Catalog table IDs explicitly selected when |
|
array |
Conditionally required |
Catalog file IDs explicitly selected when |
|
array |
No |
Catalog table IDs to exclude when selecting all. |
|
array |
No |
Catalog file IDs to exclude when selecting all. |
|
object |
No |
Further filter by table name, file name, or extension. |
In field paths, [] means each item in an array. For example, source_selections[].kind is the kind field of each item in source_selections.
Selection scope¶
Scope |
|
Scope identifier |
Explicit selection field |
|---|---|---|---|
Database |
|
|
|
Volume |
|
|
|
Do not use another kind or data sources outside Catalog.
Successful response¶
Returns 200 on success. data returns the source quantity after deduplication; confirm the quantity before adding the source.
{
"code": "OK",
"msg": "OK",
"data": {
"file_count": 2,
"table_count": 1,
"total_count": 3
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
integer |
The number of file sources that will be added after deduplication. |
|
integer |
The number of table sources that will be added after deduplication. |
|
integer |
Total number of file and table sources. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid source selection",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Correct your selections and try again. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have permission to update the knowledge base or read the selected source. |
Check workspace and object authorization. |
|
|
The knowledge base does not exist or is not visible. |
Reconfirm |
|
|
Service failed to preview source selection. |
Keep the desensitized response information and try again. |
Follow-up operations¶
After confirming the quantity Add data source.