用途:直接发送原生的JSON内容到Elasticsearch。
依赖类:\x\Elasticsearch
方法名:exec()
参数:
string $url
string $verb
\x\elasticsearch\tool\Client
类获得。json|array $json
返回值:请求失败返回false
,请求成功返回解析后的array
结构内容。
使用示例:
// 组件
use x\Elasticsearch;
// 动词库
use x\elasticsearch\tool\Client;
// ES组件
$Elasticsearch = new Elasticsearch();
// 执行原生查询
$body = [
'query' => [
'match' => [
'content' => 'quick brown fox'
]
],
'highlight' => [
'fields' => [
'content' => new \stdClass()
]
]
];
$res = $Elasticsearch->exec('/shop/_search', Client::GET, $body);
var_dump($res);
class AbstractClient
{
// ---------------------HTTP动词---------------------
const GET = 'GET';
const POST = 'POST';
const HEAD = 'HEAD';
const OPTIONS = 'OPTIONS';
const PUT = 'PUT';
const DELETE = 'DELETE';
const TRACE = 'TRACE';
const CONNECT = 'CONNECT';
}