OpenSearchClient客户端

功能简介

OpenSearchClient客户端类,构建存储基本参数对象,包含的参数有,AK信息,应用API访问host地址,options选项等,并作为SearcherClient对象的构造函数参数,用于与服务器交互。

构造函数

函数定义

void    OpenSearch\Client\OpenSearchClient::__construct($accessKey,$secret, $host,$options)

参数描述

参数名称

类型

描述

accessKey

string

指定您的accessKeyId,在 ram.console.aliyun.com/manage/ak中可以创建。(建议您使用RAM子账号功能,创建独立的RAM子钥匙访问应用)。

secret

string

用户的secret,对应的Access Key Secret。

host

string

指定请求的host地址,例如外网杭州区域为:https://opensearch-cn-hangzhou.aliyuncs.com

options

mixed

指定一些可选参数,例如:debug,gzip,connectTimeout,timeout 等。

options: 包含下面一些可选信息

参数名称

参数类型

参数描述

debug

boolean

true/false,是否开启debug模式(默认不开启)

gzip

boolean

true/false 是否开启gzip压缩(默认不开启)

connectTimeout

int

连接超时时间,seconds(默认1秒)

timeout

int

超时时间,seconds(默认10秒)


发送一个GET请求

以GET请求方式召回数据

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::get( $uri,  $params)

参数描述

参数名称

类型

描述

$uri

string

发起GET请求的uri。

$params

array

发起GET请求的参数,以param_key => param_value的方式体现。


发送一个POST请求

以POST请求方式召回数据

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::post( $uri,  $body)

参数描述

参数名称

类型

描述

$uri

string

发起POST请求的uri。

$body

string

发起POST请求的body体,为一个原始的JSON格式的string。


发送一个PUT请求

用于推送文档数据

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::put( $uri,  $body)

参数描述

参数名称

类型

描述

$uri

string

发起PUT请求的uri。

$body

string

发起PUT请求的body体,为一个原始的JSON格式的string。


发送一个DELETE请求

用于删除文档数据

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::delete( $uri,  $body)

参数描述

参数名称

类型

描述

$uri

string

发起DELETE请求的uri。

$body

string

发起DELETE请求的body体,为一个原始的JSON格式的string。


发送一个PATCH请求

该方法用户层面基本接触不到,大致了解即可,用于更新已存在应用信息。

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::patch( $uri,  $body)

参数描述

参数名称

类型

描述

$uri

string

发起PATCH请求的uri。

$body

string

发起PATCH请求的body体,为一个原始的JSON格式的string。


发送一个call请求

该方法用户层面基本接触不到,大致了解即可,更新应用通用函数。

函数定义

\OpenSearch\Generated\Common\OpenSearchResult     OpenSearch\Client\OpenSearchClient::call( $uri,  $params,  $body,  $method)

参数描述

参数名称

类型

描述

$uri

string

发起请求的uri。

$params

array

指定的URL中的query string 列表。

$body

string

发起请求的body体,为一个原始的JSON格式的string。

$method

string

发起请求的方法,有GET/POST/DELETE/PUT/PATCH等

阿里云首页 智能开放搜索 OpenSearch 相关技术圈