lacasera/elastic-bridge

An eloquent way to search

Fund package maintenance!
Lacasera

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 5

pkg:composer/lacasera/elastic-bridge

v1.0.2 2025-10-25 23:48 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

ElasticBridge allows you to write Fluent, Eloquent like Elasticsearch queries in your laravel application.

With ElasticBridge, you can interact with Elasticsearch indexes as easily as you would with traditional Eloquent models, bringing the power of Elasticsearch into the Laravel ecosystem with no effort.

This package simplifies the complexity of Elasticsearch queries, allowing you to execute powerful search operations while maintaining the elegance and familiarity of Laravel's syntax.

Requirements

  • PHP 8.2 or 8.3
  • Laravel 10.x, 11.x, or 12.x
  • Elasticsearch 8.x

Compatibility Matrix

Laravel Version PHP Version Testbench Version Carbon Version PHPUnit Version
10.x 8.2, 8.3 8.* ^2.63 ^10.5
11.x 8.2, 8.3 9.* ^2.63 ^10.5
12.x 8.3 10.* ^3.8.4 ^11.5.3

Installation

Install the package via Composer:

composer require lacasera/elastic-bridge

Overview

    php artisan make:bridge HotelRoom
<?php 
declare(strict_types=1);

namespace App\Bridges;

use Lacasera\ElasticBridge\ElasticBridge;

class HotelRoom extends ElasticBridge 
{
       
}
<?php
declare(strict_types=1);

namespace App\Http\Controllers;

use App\Bridges\HotelRoom;
use App\Requests\SearhRequest;

class SearchController extends  Controller
{
    public function __invoke(SearhRequest $request)
    {
        $rooms = HotelRoom::asBoolean()
            ->matchAll()
            ->orderBy('price', 'DESC'),
            ->filterByTerm('code', 'usd')
            ->filterByRange('price', 20, 'gte')
            ->filterByRange('price', 500, 'lte')
            ->cursorPaginate(50)
            ->get(['price']);
            
            
        return response()->json([
            'data' => $rooms
        ]);
    }
}

Documentation

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

TODO [] Add logging for queries and response...