OpenSearch class

Updated at:

The OpenSearch class stores the credentials and endpoint configuration used to create an OpenSearchClient object. It is thread-safe and can be shared across multiple threads without creating a new instance per request.

Method summary

MethodDescription
OpenSearch(String accesskey, String secret, String host)Creates an instance with credentials and an endpoint
OpenSearch()Creates an instance without parameters. Configure it later using setters
setAccessKey(String accesskey)Sets the AccessKey ID
getAccessKey()Returns the AccessKey ID
setSecret(String secret)Sets the AccessKey secret
getSecret()Returns the AccessKey secret
setHost(String host)Sets the API endpoint
getHost()Returns the API endpoint
setOptions(Map<String,String> options)Sets additional options
getOptions()Returns the configured options

Constructors

OpenSearch(String accesskey, String secret, String host)

Creates an OpenSearch instance with credentials and an endpoint in a single call. Use this constructor when all configuration values are available upfront.

Parameters

ParameterTypeDescription
accesskeyStringYour Alibaba Cloud AccessKey ID. You can obtain the AccessKey ID from the Alibaba Cloud Management Console.
secretStringYour Alibaba Cloud AccessKey secret. You can obtain the AccessKey secret from the Alibaba Cloud Management Console.
hostStringThe OpenSearch API endpoint for your region.

OpenSearch()

Creates an OpenSearch instance with no parameters. Use this constructor when you need to configure credentials and the endpoint separately using setAccessKey(), setSecret(), and setHost().

Methods

setAccessKey

Sets the AccessKey ID.

OpenSearch    setAccessKey(String accesskey)

Parameters

ParameterTypeDescription
accesskeyStringYour Alibaba Cloud AccessKey ID. You can obtain the AccessKey ID from the Alibaba Cloud Management Console.

getAccessKey

Returns the configured AccessKey ID.

String    getAccessKey()

Return value

The AccessKey ID. Type: String.

setSecret

Sets the AccessKey secret.

OpenSearch    setSecret(String secret)

Parameters

ParameterTypeDescription
secretStringYour Alibaba Cloud AccessKey secret. You can obtain the AccessKey secret from the Alibaba Cloud Management Console.

getSecret

Returns the configured AccessKey secret.

String    getSecret()

Return value

The AccessKey secret. Type: String.

setHost

Sets the OpenSearch API endpoint.

OpenSearch    setHost(String host)

Parameters

ParameterTypeDescription
hostStringThe OpenSearch API endpoint for your region.

getHost

Returns the configured OpenSearch API endpoint.

String    getHost()

Return value

The API endpoint. Type: String.

setOptions

Sets additional options.

OpenSearch    setOptions(Map<String,String> options)

Parameters

ParameterTypeDescription
optionsMap<String,String>The options to configure.

getOptions

Returns the configured options.

Map<String,String>    getOptions()

Return value

The configured options. Type: Map<String,String>.