Create semantic entries¶
Create semantic configuration entries to supplement data tables with field, metric, correlation, and business rule definitions.
POST $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/entries
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. 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/entries" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"kind": "metric",
"key": "gmv",
"tables": [
"orders"
],
"spec": {
"name": "GMV",
"metric_type": "aggregate",
"aggregation": "SUM",
"field": "amount",
"source_table": "orders"
}
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
The knowledge base ID for which the semantic entry is to be created. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
semantic domain. When creating and updating, omitting this field defaults to |
|
string |
Yes |
The entry type determines the structure of |
|
string |
Yes |
The entry’s reference key. Cannot be empty. |
|
array of string or null |
No |
The associated table name, not the Catalog table ID. |
|
object |
Yes |
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. |
|
string |
No |
Key. |
|
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.
Entries are uniquely keyed by a combination of domain, kind, and the normalized key. Imports and substitutions are also checked against this combination.
relationship must be filled with left_table, right_table and non-empty conditions. join_type defaults to left and supports left, inner, right and full. The conditional operator defaults to equals. For other operators, see the field description.
The combination requirements for each type of spec are as follows:
Type |
Configuration requirements |
|---|---|
metric |
|
table_description |
Fill in non-empty |
field_description |
Fill in non-empty |
business_rule |
Fill in non-empty |
constraint |
Fill in non-empty |
relationship |
|
standard_qa |
Fill in non-empty |
dynamic_query |
|
The type of the filter tree is group or condition. group uses and / or with non-null children.
condition.operator supports equals, not_equals, in, not_in, contains, between, is_null, is_not_null. In addition to the two null value judgment operations, value must be provided. Explicit null is also a supplied value.
type of the formula tree supports metric_ref, constant, add, subtract, multiply and divide.
metric_ref: Use non-nullkeyto reference an existing indicator, and the indicator reference cannot form a cycle.constant:valuethat is notnullmust be filled in,0is allowed.Binary operations:
leftandrightare required.
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": {
"id": 501,
"domain": "nl2sql",
"kind": "metric",
"key": "gmv",
"tables": [
"orders"
],
"spec": {
"name": "GMV",
"metric_type": "aggregate",
"aggregation": "SUM",
"field": "amount",
"source_table": "orders"
},
"created_at": 1735632000,
"updated_at": 1735632000
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
New entry ID. |
|
string |
The actual semantic domain of the entry. Value: |
|
string |
The type of entry created. Values: |
|
string |
The entry’s reference key. |
|
array of string |
Association table name. Can be omitted if not set. |
|
object |
The configuration,structure of the entry depends on |
|
string |
SQL preview. |
|
integer |
Unix timestamp. |
|
integer |
Unix timestamp. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid semantic entry",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Error description. |
|
null |
|