2017 © Pedro Peláez
 

library think-elasticsearch

A encapsulation interface for elasticsearch php api.

image

syqmk/think-elasticsearch

A encapsulation interface for elasticsearch php api.

  • Thursday, April 19, 2018
  • by shaoyuansy
  • Repository
  • 0 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

根据Elasticsearch-PHP [6.0] 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';

}

esGet

条件查询, (*4)

例如:

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

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

esGetById

根据ID查询, (*5)

例如:

$id = "VdOa3GIBv0F8YUCs1PVZ";

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

esInsert

插入一条数据, (*6)

例如:

$id = null;

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

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

esInsertAll

批量插入数据, (*7)

例如:

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

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

esUpdateById

修改记录, (*8)

例如:

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

$id = 'VdOa3GIBv0F8YUCs1PVZ';

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

esDeleteById

删除一条记录, (*9)

例如:

$id = 'VNOa3GIBv0F8YUCs1PVZ';

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

esDeleteByIds

批量删除, (*10)

例如:

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

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

The Versions

19/04 2018

dev-master

9999999-dev

A encapsulation interface for elasticsearch php api.

  Sources   Download

MIT

The Requires

 

by ShaoYuan

19/04 2018

1.0.0

1.0.0.0

A encapsulation interface for elasticsearch php api.

  Sources   Download

MIT

The Requires

 

by ShaoYuan