dev-master
9999999-devA encapsulation interface for elasticsearch php api.
MIT
The Requires
by ShaoYuan
1.0.0
1.0.0.0A encapsulation interface for elasticsearch php api.
MIT
The Requires
by ShaoYuan
Wallogit.com
2017 © Pedro Peláez
A encapsulation interface for elasticsearch php api.
目前根据开发时的实际业务,封装了部分方法,简化查询,会持续更新, (*1)
以下类库都在
\\think\\elasticsearch命名空间下, (*2)
需要继承 \think\elasticsearch\ES 类,覆盖es配置, (*3)
例如:
use think\elasticsearch\ES;
class Esdb extends ES {
protected $esHost = ['192.168.2.11'];
protected $esIndex = 'think';
protected $esType = 'user';
}
条件查询, (*4)
例如:
$filter = [
'query' => [
"bool" => [
'must' => [
'term'=>['email.keyword'=>'test@think.com']
]
]
]
];
$result = Esdb::esGet($filter);
根据ID查询, (*5)
例如: $id = "VdOa3GIBv0F8YUCs1PVZ"; $result = Esdb::esGetById($id);
插入一条数据, (*6)
例如:
$id = null;
$data = [
"id" => "VdOa3GIBv0F8YUCs1PVZ"
"content" => "test",
];
$result = Esdb::esInsert($data, $id);
批量插入数据, (*7)
例如:
$data_list = [
[
"id" => "VdOa3GIBv0F8YUCs1PVZ",
"content" => "test",
],
[
"id" => "VdOa3GIBv0F8YUCs1PVX",
"content" => "test",
]
];
$result = Esdb::esInsertAll($data_list);
修改记录, (*8)
例如:
$data = [
"content"=>"think"
];
$id = 'VdOa3GIBv0F8YUCs1PVZ';
$result = Esdb::esUpdateById($data, $id);
删除一条记录, (*9)
例如: $id = 'VNOa3GIBv0F8YUCs1PVZ'; $result = Esdb::esDeleteById($id);
批量删除, (*10)
例如: $ids = ['gNPW3GIBv0F8YUCsbPUZ',"VdOa3GIBv0F8YUCs1PVX"]; $result = Esdb::esDeleteByIds($id);
A encapsulation interface for elasticsearch php api.
MIT
A encapsulation interface for elasticsearch php api.
MIT