Download the PHP package ljw/es without Composer

On this page you can find all versions of the php package ljw/es. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package es

es使用

安装

composer require ljw/es:dev-master

配置

//配置es
\Ljw\Es\Es::$hosts = '127.0.0.1';
\Ljw\Es\Es::$port = '9200';

开始使用

建立索引

class Product extends \Ljw\Es\Model
{
    //指定索引
    protected $index = 'product_index';
    //指定索引别名
    protected $alias = 'product_alias';
    //指定type
    protected $type = 'products';
    /**
     * 索引设置
     * @var array
     */
    protected $setting = [];
    /**
     * 索引参数
     * @var array
     */
    protected $properties = [
        'id'             => ['type' => 'long'],
        'name'           => ['type' => 'string'],
        'description'    => ['type' => 'string'],
    ];

}

{class} 为类名小写

查询

  1. 直接查询
    //简单查询,where只支持 = , > , < , >= , <= , between ; = 就相当于like了
    // where ... or ... and (... or ...) order by `id` `desc` 
    $query = \Ljw\Es\Es::query()
    ->index('pro_index')
    ->type('type')
    ->where(...)
    ->orWhere(...)
    ->where(function ($q) {
        $q->where(...)->orWhere(...);
    })
    ->order('id', 'desc')
    ->page($page, $page_size)
    ->search();
    $list = $query->getData(); //数据列表
    $count = $query->getCount(); //数据总量
    // ---------------
    // 聚合,支持 group,avg,sum,max,min
    $query = \Ljw\Es\Es::query()
    ->index('pro_index')
    ->type('type')
    ->where(...)
    ->group('xxx', function($q){  //  group by xxx 并计算不同xxx下面aaa的和
        $q->sum('aaa');
    })
    ->sum('id') // 计算id的和
    ->search();
    $data = $query->getData();
  2. 创建模型查询
    
    class Product extends \Ljw\Es\Model
    {
    //指定索引
    protected $index = 'product_index';
    //指定索引别名
    protected $alias = 'product_alias';
    //指定type
    protected $type = 'products';
    protected $setting = [...];
    protected $properties = [...];

} $re = Product::query()->where(...)->orWhere(...)->search(); $list = $re->getData(); //数据列表 $count = $re->getCount(); //数据总量 $re = Product::query()->where(...)->orWhere(...)->group(...)->search(); $data = $re->getData();


### 添加,修改,删除数据

* 建立模型
~~~php
class Product extends \Ljw\Es\Model
{
    //指定索引
    protected $index = 'product_index';
    //指定索引别名
    protected $alias = 'product_alias';
    //指定type
    protected $type = 'products';
    protected $setting = [...];
    protected $properties = [...];

}
// $id 必须为唯一id, $data为数据,会根据 $properties 自动剔除
Product::add($id, $data);
//删除
Product::delete($id);
//跟新数据
Product::update($id, $data);

注:暂时就这些简单的功能了


All versions of es with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
elasticsearch/elasticsearch Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ljw/es contains the following files

Loading the files please wait ....