The OpenSearch class holds the connection configuration — AccessKey ID, AccessKey secret, and API endpoint — used to create an OpenSearchClient object. It is thread-safe: create one instance at application startup and reuse it across threads.
Method summary
| Method | Signature | Description |
|---|---|---|
| Constructor (parameterized) | OpenSearch(String accesskey, String secret, String host) | Creates an instance with an AccessKey pair and API endpoint |
| Constructor (no-arg) | OpenSearch() | Creates an instance with no initial configuration |
setAccessKey | OpenSearch setAccessKey(String accesskey) | Sets the AccessKey ID |
getAccessKey | String getAccessKey() | Returns the AccessKey ID |
setSecret | OpenSearch setSecret(String secret) | Sets the AccessKey secret |
getSecret | String getSecret() | Returns the AccessKey secret |
setHost | OpenSearch setHost(String host) | Sets the API endpoint |
getHost | String getHost() | Returns the API endpoint |
setOptions | OpenSearch setOptions(Map<String, String> options) | Sets additional options |
getOptions | Map<String, String> getOptions() | Returns the configured options |
Constructors
Constructor (parameterized)
OpenSearch(String accesskey, String secret, String host)Creates an OpenSearch instance with an AccessKey pair and API endpoint. Use this constructor when you have credentials ready at initialization time.
| Parameter | Type | Description |
|---|---|---|
accesskey | String | Your AccessKey ID. Retrieve it from the Alibaba Cloud Management Console. |
secret | String | Your AccessKey secret. Retrieve it from the Alibaba Cloud Management Console. |
host | String | The OpenSearch API endpoint for your region. |
Constructor (no-arg)
OpenSearch()Creates an OpenSearch instance with no initial configuration. Use the setter methods to supply credentials and the endpoint before creating a client.
Methods
setAccessKey
OpenSearch setAccessKey(String accesskey)Sets the AccessKey ID.
| Parameter | Type | Description |
|---|---|---|
accesskey | String | Your AccessKey ID. Retrieve it from the Alibaba Cloud Management Console. |
Return value: The OpenSearch instance.
getAccessKey
String getAccessKey()Returns the configured AccessKey ID.
Return value: The AccessKey ID. Type: String.
setSecret
OpenSearch setSecret(String secret)Sets the AccessKey secret.
| Parameter | Type | Description |
|---|---|---|
secret | String | Your AccessKey secret. Retrieve it from the Alibaba Cloud Management Console. |
Return value: The OpenSearch instance.
getSecret
String getSecret()Returns the configured AccessKey secret.
Return value: The AccessKey secret. Type: String.
setHost
OpenSearch setHost(String host)Sets the OpenSearch API endpoint for your region.
| Parameter | Type | Description |
|---|---|---|
host | String | The OpenSearch API endpoint for your region. |
Return value: The OpenSearch instance.
getHost
String getHost()Returns the configured API endpoint.
Return value: The API endpoint. Type: String.
setOptions
OpenSearch setOptions(Map<String, String> options)Sets additional options.
| Parameter | Type | Description |
|---|---|---|
options | Map<String, String> | A map of option key-value pairs. |
Return value: The OpenSearch instance.
getOptions
Map<String, String> getOptions()Returns the configured options.
Return value: The options map. Type: Map<String, String>.