flc/laravel-elasticsearch

Laravel Elasticsearch 构建类

v2.0.0 2024-02-07 10:36 UTC

This package is auto-updated.

Last update: 2024-04-07 11:03:12 UTC


README

Latest Stable Version Total Downloads License 996.icu LICENSE

安装

composer require flc/laravel-elasticsearch

版本矩阵

Package Version Elasticsearch Version Elasticsearch-PHP Branch
v2.x >= 7.x >= 7.x
v1.x >= 6.x >= 7.x

配置

使用文档

示例

<?php

use Elasticsearch;

Elasticsearch::index('users')
    ->select('id', 'username', 'password', 'created_at', 'updated_at', 'status', 'deleted')
    ->whereTerm('status', 1)
    ->orWhereIn('deleted', [1, 2])
    ->whereNotExists('area')
    ->where(['status' => 1, 'closed' => 0])
    ->where(function ($query) {
        $query->where('status', '=', 1)
            ->where('closed', 1)
            ->where('username', 'like', '张三');
            ->where('username', 'match', '李四');
    })
    ->orderBy('id', 'desc')
    ->take(2)
    ->paginate(10);
    // ->get();
    // ->search();

LICENSE

  • MIT
  • Anti 996