Overview
The OpenSearchClient class is used to construct and store basic parameter objects. The parameters include the AccessKey information, API endpoint, and options. An OpenSearchClient object can be used as a parameter in the constructor of the SearcherClient class to interact with servers.
Constructor
Method definition
void OpenSearch\Client\OpenSearchClient::__construct($accessKey,$secret, $host,$options)
Parameter description
Parameter | Type | Description |
accessKey | string | The AccessKey ID of your Alibaba Cloud account. If you do not have an AccessKey pair, see aCreate an AccessKey pair. We recommend that you use Resource Access Management (RAM) and create an AccessKey pair of a RAM user and use this AccessKey pair to access applications for higher security. |
secret | string | The AccessKey secret of your Alibaba Cloud account. |
host | string | The endpoint of the OpenSearch API in your region. For example, the public endpoint of the OpenSearch API in the China (Hangzhou) region is http://opensearch-cn-hangzhou.aliyuncs.com. |
options | mixed | The optional parameters such as debug, gzip, connectTimeout, and timeout. |
options
Parameter | Type | Description |
debug | boolean | Specifies whether to enable the debugging mode. Valid values: true and false. Default value: false. |
gzip | boolean | Specifies whether to enable GZIP compression. Valid values: true and false. Default value: false. |
connectTimeout | int | The timeout period of connections, in seconds. Default value: 1. |
timeout | int | The timeout period of responses, in seconds. Default value: 10. |
get
Sends a GET request to retrieve data.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::get( $uri, $params)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the GET request is initiated. |
$params | array | The parameters in the GET request. Each parameter is in the param_key => param_value format. |
post
Sends a POST request to retrieve data.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::post( $uri, $body)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the POST request is initiated. |
$body | string | The body of the POST request, in the form of a raw JSON string. |
put
Uploads document data.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::put( $uri, $body)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the PUT request is initiated. |
$body | string | The body of the PUT request, in the form of a raw JSON string. |
delete
Deletes document data.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::delete( $uri, $body)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the DELETE request is initiated. |
$body | string | The body of the DELETE request, in the form of a raw JSON string. |
patch
Updates the information about an existing application. This method is rarely used by users.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::patch( $uri, $body)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the PATCH request is initiated. |
$body | string | The body of the PATCH request, in the form of a raw JSON string. |
call
Updates an application. This method is rarely used by users.
Method definition
\OpenSearch\Generated\Common\OpenSearchResult OpenSearch\Client\OpenSearchClient::call( $uri, $params, $body, $method)
Parameter description
Parameter | Type | Description |
$uri | string | The URI to which the request is initiated. |
$params | array | The query strings in the specified URL. |
$body | string | The body of the request, in the form of a raw JSON string. |
$method | string | The method to initiate the request, such as GET, POST, DELETE, PUT, and PATCH. |