ss-wiking/elastic-orm

Elasticsearch ORM like Eloquent

v0.3.2-alpha.3 2022-03-30 09:24 UTC

README

Latest Version on Packagist Total Downloads GitHub Actions

High level Elasticsearch ORM for Laravel with query builder and models

Installation

You can install the package via composer:

composer require ss-wiking/elastic-orm

Usage

Model

use SsWiking\ElasticOrm\Model;

class Product extends Model {
    /**
     * Model index name
     * If not provided, it will be got from model name in plural form
     *
     * @var string
     */
    protected string $index = 'products';
}

Query Builder via Model

$products = Product::whereIn('id', $ids)
    ->whereGreaterThan('price', $minPrice)
    ->get();

Query Builder via Facade

use SsWiking\ElasticOrm\Facades\ElasticOrm;

ElasticOrm::index('goods')->limit(10)->offset(10)->get();

Publishing config

php artisan vendor:publish --provider="SsWiking\ElasticOrm\Providers\ElasticOrmServiceProvider" --tag=config

Generate model's meta

php artisan elastic-orm:meta "App\Models\Elastic\YourModelName"

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ss.wiking@outlook.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.