assert6 / hyperf-elasticsearch
There is no license information available for the latest version (v3.2.0) of this package.
Hyperf ElasticSearch Client
v3.2.0
2025-01-17 03:53 UTC
Requires
- php: >=8.1
- ext-swoole: >=5.0
- elasticsearch/elasticsearch: ^7.0
- hyperf/collection: ~3.1.0
- hyperf/contract: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/framework: ~3.1.0
- hyperf/guzzle: ~3.1.0
- hyperf/logger: ~3.1.0
- hyperf/support: ~3.1.0
Requires (Dev)
- friendsofhyperf/rector: ^0.1.5
- friendsofphp/php-cs-fixer: ^3.41
- roave/security-advisories: dev-master
README
Composer
composer require assert6/hyperf-elasticsearch
Model
- index 相当于mysql中的表
<?php declare(strict_types=1); namespace App\EsModel; use Janartist\Elasticsearch\Model; class OrderModel extends Model { /** * 索引 * */ protected $index = 'chungou-order'; /** * 字段类型,创建索引中用 * */ protected $casts = ['name' => [ "type" => "text", "analyzer" => "ik_max_word", "search_analyzer" => "ik_smart" ]]; }
查询
<?php OrderModel::query()->where('name', 'zhangsan')->get(); OrderModel::query()->where('name', 'zhangsan')->first(); OrderModel::query()->whereIn('name', ['zhangsan'])->first(); OrderModel::query()->whereLike('name', 'zhangsan')->first(); OrderModel::query()->find();
新增修改删除
<?php OrderModel::query()->create([]); OrderModel::query()->insert([[],[]]); OrderModel::query()->delete([], '23asdq'); OrderModel::query()->update([], '23asdq');