lacasera/
elastic-bridge
g4t.io

Elastic Bridge: Eloquent-Style Queries for Elasticsearch and OpenSearch

68 views 18 stars by Yannick Lyn Fatt

An eloquent way to search

README from lacasera/elastic-bridge Open on GitHub →

An Eloquent Way To Search.

Latest Version on Packagist Total Downloads

ElasticBridge allows you to write Fluent, Eloquent like queries against Elasticsearch and OpenSearch in your Laravel application.

With ElasticBridge, you can interact with your search indexes as easily as you would with traditional Eloquent models — full-text search, filters, aggregations, attribute casting, bulk indexing, and multi-index queries — bringing the power of Elasticsearch/OpenSearch into the Laravel ecosystem with no effort.

Requirements

  • PHP 8.2 or 8.3
  • Laravel 10.x, 11.x, or 12.x
  • Elasticsearch 8.x or OpenSearch 2.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

AI-assisted development

ElasticBridge is built to be first-class for AI coding agents:

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...

More from the ecosystem

durable-workflow/
workflow
g4t.io
9 1,292

Durable Workflow: Long-Running Workflows for Laravel

Embedded durable workflow runtime and orchestration engine for Laravel applications.

durable-workflow/workflow via Laravel News
packstub/
session-replay
g4t.io
14 52

Session Replay for Laravel: Self-Hosted Browser Recordings

Session replay for Laravel: record what a person did in the browser with rrweb, keep the recording on your own disk and database, and watch it behind a gate you define — masked inputs by default, errors, failed Livewire requests and web vitals marked on the timeline, a link to the replay in every log line. packstub/filament-session-replay adds the sessions to a Filament panel.

packstub/session-replay via Laravel News
cyberwizard-dev/
schedule-catchup
g4t.io
17

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Schedule Catchup replays missed Laravel scheduled tasks after downtime, with opt-in recovery, bounded retries, and access to the original scheduled date.

cyberwizard-dev/schedule-catchup via Laravel News