Skip to content

for Laravel · Elasticsearch & OpenSearch

ElasticBridge

An eloquent way to search.

Fluent, Eloquent-style queries for Elasticsearch and OpenSearch. No hand-built JSON DSL.

$ composer require lacasera/elastic-bridge

PHP 8.2+ · Laravel 10–12 · Elasticsearch 8.x / OpenSearch 2.x

Query in, hits out

A bridge is a model for your index. Define it, query it in a controller, fake it in a test.

php
<?php

namespace App\Bridges;

use Lacasera\ElasticBridge\ElasticBridge;

class HotelRoom extends ElasticBridge
{
    protected $index = 'hotel-rooms';
}

Everything a search model needs

Bridges behave like the Eloquent models you already know.

Seamless Laravel Integration

An intuitive, Eloquent-like syntax for your search cluster. Index, search, and query without complex configuration.

Elasticsearch & OpenSearch

Choose your backend with a single config value. One fluent API across both drivers, with basic-auth, API key, and AWS SigV4.

Advanced Query Capabilities

Multi-match queries, aggregations, filtering, geo queries, and full-text search — ranked hits, straight back.

Testing

Mock and assert your search queries without a live cluster. Fast suites, no containers required.

Pagination

Length-aware and cursor pagination out of the box, mirroring Laravel's paginator APIs.

Casting, Accessors & Mutators

Shape documents on the way in and out with attribute casting, accessors, and mutators — just like Eloquent.

Works with your stack

  • PHP 8.2 · 8.3
  • Laravel 10 / 11 / 12
  • Elasticsearch 8.x
  • OpenSearch 2.x

Explore the docs

Jump straight to what you need.

Released under the MIT License.