All Products
Search
Document Center

OpenSearch:CreateFunctionInstance

Last Updated:Jun 17, 2024

Creates an algorithm instance of a feature.

Operation description

You can call the GetFunctionCurrentVersion operation to query the latest version of a feature. The response of the operation includes the createParameters parameter that is used to create an algorithm instance, the usageParameters parameter, and the requirements for setting these parameters.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
opensearch:WriteFunctionWrite
  • All Resources
    *
    none
none

Request syntax

POST /v4/openapi/app-groups/{appGroupIdentity}/functions/{functionName}/instances

Request parameters

ParameterTypeRequiredDescriptionExample
BodyobjectYes

The request body.

instanceNamestringYes

The instance name. The name must be 1 to 30 characters in length and can contain letters, digits, and underscores (_). The name is case-sensitive and must start with a letter.

ctr_test
modelTypestringYes

The model type. The value varies based on the model.

  • Click-through rate (CTR) model: tf_checkpoint
  • Popularity model: pop
  • Category model: offline_inference
  • Hotword model: offline_inference
  • Hint model: offline_inference
  • Hotword model for real-time top searches: near_realtime
  • Personalized hint model: near_realtime
  • Drop-down suggestion model: offline_inference
  • Tokenization model: text
  • Term weight model: tf_checkpoint
  • Synonym model: offline_inference
tf_checkpoint
functionTypestringNo

The feature type.

  • Default value: PAAS. Training is required before you can use the feature.
PAAS
descriptionstringNo

The description.

test instance
createParametersobject []No

The parameters used to create the instance.

[ { "name": "param1", "value": "val1" } ]
namestringNo

The parameter name.

title_field
valuestringNo

The parameter value.

title
usageParametersobject []No

The parameters used to use the instance.

namestringNo

The parameter name.

allow_dict_id
valuestringNo

The parameter value.

123
cronstringNo

The CRON expression used to schedule periodic training, in the format of Minutes Hours DayofMonth Month DayofWeek. The default value is empty, which specifies that no periodic training is performed. A value of 0 for DayofWeek specifies Sunday.

0 0 ? * 0,1,2,3,4,5,6
appGroupIdentitystringYes

The name of the application.

my_app_group_name
functionNamestringYes

The feature name. Valid values:

  • ctr: CTR model.
  • pop: popularity model.
  • category: category model.
  • hot: hotword model.
  • hint: hint model.
  • suggest: drop-down suggestion model.
  • analyzer: tokenization model.
  • termweight: term weight model.
  • synonym: synonym model.
ctr

Sample requests (In this example, the functionName parameter is set to ctr.)

POST /v4/openapi/app-groups/my-app/functions/ctr/instances
{
    "instanceName": "my_ctr",
    "modelType": "tf_checkpoint",
    "functionType": "PAAS",
    "cron": "0 0 ? * 0,1,3,5",
    "description": "",
    "createParameters": [
        {
            "name": "id_field",
            "value": "id"
        },
        {
            "name": "title_field",
            "value": "title"
        }
    ],
    "usageParameters": []
}

Sample requests (In this example, the functionName parameter is set to hot.)

POST /v4/openapi/app-groups/my-app/functions/hot/instances
{
    "instanceName":"my_hot",
    "modelType":"offline_inference",
    "functionType":"PAAS",
    "createParameters":[
        {
            "name":"filter",
            "value":"biz_type != 1"
        }
    ],
    "usageParameters": [
        {
            "name":"allow_dict_id",
            "value":"123"
        },
        {
            "name":"deny_dict_id",
            "value":"456"
        }
    ],
    "cron":"12 4 ? * 1,2,3,4,5,6,0"
}

Response parameters

ParameterTypeDescriptionExample
object

The parameter body.

Statusstring

The status of the request.

OK
HttpCodelong

The HTTP status code.

200
RequestIdstring

The ID of the request.

98724351-D6B2-5D8A-B089-7FFD1821A7E9
Messagestring

The error message. If no error occurs, this parameter is left empty.

version not exist.
Codestring

The error code.

Version.NotExist
Latencylong

The time consumed for the request, in milliseconds.

123

Sample success responses

{
  "status" : "OK",
  "requestId" : "98724351-D6B2-5D8A-B089-7FFD1821A7E9",
  "httpCode": 200,
  "code": "",
  "message": "",
  "latency" : 123,
  "result" : {}
}

Examples

Sample success responses

JSONformat

{
  "Status": "OK",
  "HttpCode": 200,
  "RequestId": "98724351-D6B2-5D8A-B089-7FFD1821A7E9",
  "Message": "version not exist.",
  "Code": "Version.NotExist",
  "Latency": 123
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-03-30The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.
2023-03-28The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.