Import semantic entries¶
Import semantic entries into the knowledge base in batches, with the option of appending or overwriting, and previewing before writing.
POST $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/import
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First query the knowledge base list to obtain the knowledge base ID, and confirm the existing semantic entries of the target knowledge base and the import method this time. Prepare a personal access token and target workspace ID that can access the target workspace.
Request body¶
Replace $MODEL_ID, $CLOUDSIGMA_API_KEY, $WORKSPACE_ID in the example with actual values.
curl -X POST "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/import" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"entries": [
{
"kind": "metric",
"key": "total_rows",
"spec": {
"name": "GMV",
"metric_type": "aggregate",
"aggregation": "SUM",
"field": "amount"
}
}
]
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Receives the imported knowledge base ID. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
Import format. Value: empty string, |
|
string |
No |
Semantic entry format version. Value: empty string, |
|
string |
No |
processing mode. Values: empty string, |
|
boolean |
No |
Is it a preview? |
|
boolean |
No |
Confirm coverage. |
|
array of object |
Yes |
For entries to be imported, existing entries are processed in append/overwrite mode. At least 1 items. |
|
string |
No |
semantic domain. When creating and updating, omitting this field defaults to |
|
string |
When the object is provided |
The entry type determines the structure of |
|
string |
When the object is provided |
key. Cannot be empty. |
|
array of string or null |
No |
Table reference. |
|
object |
When the object is provided |
Fill in the configuration listed in this section according to |
|
string |
No |
semantic domain. When creating and updating, omitting this field defaults to |
|
string |
No |
The entry type determines the structure of |
|
string |
No |
Key. |
|
array of string or null |
No |
Table reference. |
|
object |
No |
Fill in the configuration listed in this section according to |
|
string |
Yes |
Name. |
|
array of string or null |
No |
Synonyms. |
|
string |
No |
Description. |
|
string |
No |
Source table. |
|
string |
Yes |
Indicator type. |
|
string |
No |
Aggregation functions. |
|
string |
No |
field. |
|
object or null |
No |
Filter tree. |
|
string |
No |
type. |
|
string |
No |
Conditional connection method. |
|
array of object or null |
No |
sub-condition. |
|
string |
No |
field. |
|
string |
No |
Comparison operators. |
|
any |
No |
Value. |
|
number |
No |
Multiplier. |
|
object or null |
No |
Formula tree. |
|
string |
No |
type. |
|
string |
No |
Key. |
|
number or null |
No |
Value. |
|
object or null |
No |
left operand. |
|
object or null |
No |
Right operand. |
|
string |
No |
type. |
|
string |
No |
Conditional connection method. |
|
array of object or null |
No |
sub-condition. |
|
string |
No |
Comparison operators. |
|
any |
No |
Value. |
|
number or null |
No |
Value. |
|
object or null |
No |
left operand. |
|
object or null |
No |
Right operand. |
|
string |
No |
Table name. |
|
string |
Yes |
Description. |
|
string |
Yes |
Column name. |
|
boolean or null |
No |
Whether to enable natural language conversion to SQL. |
|
string |
Yes |
Business rules. |
|
array of string or null |
No |
File configuration. |
|
string |
No |
Migration status. |
|
object |
Yes |
Filter tree. |
|
string |
Yes |
Table left. |
|
string |
Yes |
Right table. |
|
string |
No |
Connection type. |
|
array of object or null |
No |
Connection conditions. |
|
string |
No |
Comparison operators. |
|
string |
No |
left operand. |
|
string |
No |
Right operand. |
|
string |
No |
left operand. |
|
string |
No |
Right operand. |
|
string |
Yes |
question. |
|
array of string or null |
No |
Similar questions. |
|
string |
No |
SQL text. |
|
string |
No |
answer. |
|
string |
No |
Usage. |
|
string |
No |
Query key. |
|
string |
Yes |
SQL text. |
|
string |
No |
processing method. |
domain supports nl2sql and rag. When creating and updating, omit domain and default to nl2sql. You can filter by domain when querying the list.
nl2sqlsupports the 8 entries listed in the following table.ragonly supportsbusiness_ruleandstandard_qa.standard_qaFill in a single read-only SQL innl2sql, and fill inanswerinrag.
domain in the response is the domain to which the entry actually belongs.
mode defaults to append, and overwrite is also supported. format defaults to moi.knowledge.semantics. schema_version supports empty string or 1.3.
The target knowledge base may already have entries. When overwriting, set confirm_overwrite to true. There is no need to confirm coverage during the preview. The service first verifies the complete set of entries, and then saves them in the selected mode after passing them.
children is an array of nodes with the same structure. Fill in recursively according to the field definitions in this section.
left and right are formula nodes with the same structure. Fill in recursively according to the field definitions in this section.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"imported": 1,
"model_id": 401
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
The number of entries imported and written this time. |
|
integer |
Remove mark or quantity. |
|
boolean |
Is it a preview? |
|
integer |
Receives the imported knowledge base ID. |
Error response¶
{
"code": "ErrConflict",
"msg": "duplicate semantic entry key",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Error description. |
|
null |
|