Skip to content

guandeng/elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elasticsearch

Latest Stable Version Total Downloads GitHub license

A component for elasticsearch

Installation

composer require guandeng/elasticsearch

Publish configure

php bin/hyperf.php vendor:publish guandeng/elasticsearch

Usage

Index

  • Create
namespace App\Indices;

use Guandeng\Elasticsearch\Index\AbstractIndex;

class Test extends AbstractIndex
{
    protected $index = 'test';
}
  • Create by command
php bin/hyperf.php gen:index test
  • Query
use App\Indices\Test;

Test::query()->where(...)->search();
  • UpdateByQuery
use App\Indices\Test;

Test::query()->where(...)->script(['source' => 'ctx.source.xxx = value'])->updateByQuery();
  • Count
use App\Indices\Test;

Test::query()->where(...)->count();

Migrate

  • Index
namespace App\Indices;

use Guandeng\Elasticsearch\Index\AbstractIndex;

class Test extends AbstractIndex
{
    protected $index = 'test';
    protected $type = '_doc';
    protected $settings = [
        // your settings
    ];
    protected $properties = [
        // your properties
    ];

    public function getMigration(): Closure
    {
        return function ($index) {
            // migrate data
        };
    }
}
  • Run migrate
php bin/hyperf.php elasticsearch:migrate "App\\Indices\\Test" [--migrate] [--update] [--recreate]

ClientProxy

namespace App\Proxy;

use Guandeng\Elasticsearch\ClientProxy;

class FooClient extends ClientProxy
{
    protected $poolName = 'foo';
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages