lacasera/elastic-bridge
lacasera/elastic-bridge is a Laravel package that connects Eloquent models with Elasticsearch. It lets you index and sync records automatically, then search them through a clean, familiar query builder—an easy way to add fast, scalable full-text search to any Laravel application.
SEARCH_DRIVER) behind the same fluent API. This de-risks the vendor decision: we can standardize on OpenSearch (license cost, AWS-native) or Elasticsearch without a rewrite, and can reverse the call later at near-zero application cost.ConnectionInterface change, BridgeBuilder::all() signature), the decision "when do we ship search features vs. when do we pay the migration tax" is now coupled. Greenfield work should start on v2; in-flight v1 work should either finish on v1 behind a pinned constraint or absorb the upgrade as a scheduled ticket.Model::bulk() / Model::upsert() with automatic chunking and a BulkResult DTO (successful(), failed(), hasErrors()) turns "can we reindex 10M documents safely?" from an engineering spike into a parameterized task (bulk.max, bulk.chunk_size). That changes estimates for search-backed migrations and index rebuilds.logs-* wildcard/comma) with a separate $writeIndex plus per-call from()/into() lets us model per-tenant or per-period indices without new infrastructure or a custom abstraction layer. This is a design decision the package now supports directly, and it removes a common reason to build an internal search wrapper.$casts parity, accessors/mutators, dotted nested attributes, and $appends mean search documents behave like models. That's a direct hit on "how much custom serialization/transformation code do we write?" — likely a meaningful reduction in bespoke DTO code and a reason not to build an in-house layer.FakeConnection via ::fake(), now driver-agnostic and no longer broken in non-dev installs, means feature tests don't require a live cluster. That lowers CI cost and shortens the loop on search-touching PRs — an engineering-velocity argument, not just a technical nicety.bool, match, terms_set, typed OrderOperator/RangeOperator) plus a batch of real bug fixes (filter-only count() silently counting everything, aggregation results leaking across requests in Octane/queue workers, decimal cast crashes, save() mutating shared builder state) converts classes of silent-wrong-results bugs into loud, early failures. For a PM, that's reduced risk on any feature where search results are user-facing or billing-adjacent.llms.txt docs slightly reduce onboarding cost for engineers or agents generating integration code — a modest but real input to "time to first working search feature."Consider it when:
ConnectionInterface implementations, BridgeBuilder::all() call sites) is small and countable.Look elsewhere when:
elasticsearch-php / opensearch-php clients directly and accept the coupling.To executives: ElasticBridge 2.0 removes search vendor lock-in from our architecture. Elasticsearch and OpenSearch become a configuration value rather than a code decision, so we can negotiate on price and switch providers without a rewrite. It also closes several correctness bugs that could have produced wrong search results silently — including a filter bug in count() and state leaking between requests in long-running workers — which reduces risk on any user-facing or reporting feature built on search. The cost is a one-time, well-documented upgrade: renamed environment variables, a config re-publish, and updating custom connection code. No new infrastructure or licensing is required.
To engineering: v2 gives us Eloquent-grade ergonomics on search documents — full $casts, accessors/mutators, dotted nested attributes, $appends — so we stop writing bespoke serialization. Model::bulk()/upsert() with chunking and a BulkResult DTO makes reindex jobs routine. Multi-index reads with a separate write index let us do per-tenant and time-series indices without a custom layer. Queries are validated at build time and throw InvalidQuery instead of failing at the cluster. ::fake() gives us driver-agnostic feature tests with no cluster in CI. The upgrade is breaking but bounded: SEARCH_* env rename (no fallback), re-publish config, implement search()/count()/index()/update()/bulk() on any custom ConnectionInterface, fix BridgeBuilder::all() call sites, and drop the removed from/to range operators in favor of gt/gte/lt/lte. Note the ceiling: Laravel 10–12 only, PHP 8.2/8.3, Carbon 3.8.4+, and illuminate/database is now a runtime dependency (for the casting layer) — worth confirming that's acceptable in any non-full-Laravel service. If we need features beyond the fluent API, we should plan to drop to the official client rather than fight the abstraction.
How can I help you explore Laravel packages today?