定制 syqmk/think-elasticsearch 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

syqmk/think-elasticsearch

Composer 安装命令:

composer require syqmk/think-elasticsearch

包简介

A encapsulation interface for elasticsearch php api.

README 文档

README

目前根据开发时的实际业务,封装了部分方法,简化查询,会持续更新

以下类库都在\\think\\elasticsearch命名空间下

说明

需要继承 \think\elasticsearch\ES 类,覆盖es配置

例如:

use think\elasticsearch\ES;

class Esdb extends ES {

    protected $esHost = ['192.168.2.11'];

    protected $esIndex = 'think';

    protected $esType = 'user';

}

esGet

条件查询

例如:

$filter = [
    'query' =>  [
        "bool"  =>  [
            'must'  =>  [
                'term'=>['email.keyword'=>'test@think.com']
            ]
        ]
    ]
];

$result = Esdb::esGet($filter);

esGetById

根据ID查询

例如:

$id = "VdOa3GIBv0F8YUCs1PVZ";

$result = Esdb::esGetById($id);

esInsert

插入一条数据

例如:

$id = null;

$data = [
    "id"       =>  "VdOa3GIBv0F8YUCs1PVZ"
    "content"  =>  "test",
];

$result = Esdb::esInsert($data, $id);

esInsertAll

批量插入数据

例如:

$data_list = [
    [
        "id"       =>  "VdOa3GIBv0F8YUCs1PVZ",
        "content"  =>  "test",
    ],
    [
        "id"       =>  "VdOa3GIBv0F8YUCs1PVX",
        "content"  =>  "test",
    ]
];

$result = Esdb::esInsertAll($data_list);

esUpdateById

修改记录

例如:

$data = [
    "content"=>"think"
];

$id = 'VdOa3GIBv0F8YUCs1PVZ';

$result = Esdb::esUpdateById($data, $id);

esDeleteById

删除一条记录

例如:

$id = 'VNOa3GIBv0F8YUCs1PVZ';

$result = Esdb::esDeleteById($id);

esDeleteByIds

批量删除

例如:

$ids = ['gNPW3GIBv0F8YUCsbPUZ',"VdOa3GIBv0F8YUCs1PVX"];

$result = Esdb::esDeleteByIds($id);

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固