All Products
Search
Document Center

OpenSearch:Data API

Last Updated:Aug 21, 2026

URL

/update/$table_name/actions/bulk

  • $table_name is instance ID_table name. For example, if the instance ID is ha-843qfng6ydhb and the table name is test, then table_name is ha-843qfng6ydhb_test.

  • The URL above omits factors such as request header parameters and encoding.

  • The URL above omits the host address for accessing the application.

Supported format

JSON

HTTP request method

POST

Header parameters

Parameter

Type

Description

authorization

string

Signature

X-Opensearch-Swift-PK-Field

string

The primary key of the index table to push. Example: id

host

string

The request host. You can view it in Instance Details > API Endpoint > API Domain. Example: ha-cn-**********.ha.aliyuncs.com

Signature mechanism

You can use the following method to calculate the signature ( authorization)

Parameter

Type

Description

accessUserName

string

The username. You can view it on the instance details page > Network Information.

accessPassWord

string

The password. You can modify it on the instance details page > Network Information.

import com.aliyun.darabonba.encode.Encoder;
import com.aliyun.darabonbastring.Client;

public class GenerateAuthorization {

 public static void main(String[] args) throws Exception {
 String accessUserName = "username";
 String accessPassWord = "password";
 String realmStr = "" + accessUserName + ":" + accessPassWord + "";
 String authorization = Encoder.base64EncodeToString(Client.toBytes(realmStr, "UTF-8"));
 System.out.println(authorization);
		}
}

The correct return format for authorization

cm9vdDp******mdhbA==

Note: When you set the authorization parameter in an HTTP request, you must add the Basic prefix.

Example:

authorization: Basic cm9vdDp******mdhbA==

Document data format (body)

[
    {
        "cmd": "add",
        "fields": {
            "id": "1",
            "title": "This is the title",
            "body": "This is the body"
        }
    },
    {
        "cmd": "delete",
        "fields": {
            "id": "3"
        }
    }
]
  • cmd: Required. Defines the operation for the document, which can be "add" or "delete". We recommend that you perform batch updates in a single request to improve network interaction and processing efficiency. "add" indicates adding a document. If a document with the same primary key already exists, a "delete" is performed first, followed by an "add". "delete" indicates deleting a document. If the document with the corresponding primary key no longer exists, the deletion is considered successful.

  • fields: Required. The content of the document to operate on. The primary key column is required, because all operations in the system are performed based on the primary key. For "delete", you only need to provide the document primary key.

  • For the Array type, use JsonArray, such as [{"fields": { "id": "0","int_array": [14,85],"string_array": ["abc","xyz"]},"cmd": "add"}].

  • Note: The outermost layer is of the JsonArray type, which supports batch operations on multiple documents.

Example

Request: (Factors such as request header parameters and encoding are omitted here.)

http://ha-cn-**********.ha.aliyuncs.com/update/$table_name/actions/bulk

//The following data to be uploaded must be placed in the body
[{
	"cmd": "add",
	"fields": {
		"id": 1,
		"name": "Test Data Push"
	}
}]

Successful response

No return parameters indicate that the push was successful.

Error response

[
    {
        "code": 3012,
        "message": "Resource not found."
    }
]

Notes

  • When you use the API or SDK to push data, the application column names are case-insensitive.

  • There are limits on the number and size when you use the API or SDK to push data. The limits vary depending on the application. For more information, see the system limit descriptions.

  • After uploading data, be sure to check the return value and retry the relevant error codes (especially error 3007). Otherwise, data loss may occur. In addition, data processing is asynchronous. A return of "OK" only indicates that the system successfully received the data. Errors during data processing are displayed in the error messages in the console, so check them promptly.

  • There is a size limit for POST data. If the total volume of documents you upload is too large (2 MB before encoding), the server refuses to accept any parameters and returns an exception.