liguizhou / elasticsearch
There is no license information available for the latest version (v1.5.2) of this package.
表查询类的elasticsearch扩展
v1.5.2
2024-03-25 09:25 UTC
Requires
- php: >=7.2
- elasticsearch/elasticsearch: ^7.0
- hyperf/framework: *
- hyperf/utils: *
This package is auto-updated.
Last update: 2024-04-25 09:37:28 UTC
README
Composer
composer require liguizhou/elasticsearch
需要注意:使用es时,需要设置max_result_window,search.max_buckets
测试的es设置为1百万
Model
- index 相当于mysql中的表
<?php declare(strict_types=1); namespace App\EsModel; use Liguizhou\Elasticsearch\Model; class OrderModel extends Model { /** * 索引 * */ protected $index = 'order'; }
查询
<?php OrderModel::query()->where('pid', '1')->get()->toArray(); OrderModel::query()->where('pid', 'in', [1,2,3])->groupBy(['pid'])->orderBy(['pid'])->get()->toArray(); OrderModel::query()->whereIn('pid', [1,2,3])->offset(0)->limit(10)->paginate();