brokerexchange/elasticbuilder
Brokerexchange ElasticBuilder offers a fluent, Laravel-friendly query builder for Elasticsearch, simplifying complex search queries, filters, and aggregations without hand-writing raw JSON while keeping search logic readable and maintainable in PHP.
Architecture fit. This is a query-construction library, not a transport or persistence layer. It sits as a leaf dependency in the search domain: application code builds a DSL structure through a fluent/object API, then hands the resulting array to an Elasticsearch client (typically elasticsearch/elasticsearch) for execution. That positioning is architecturally clean — it does not own connection management, retries, or index lifecycle, so it does not conflict with existing Laravel service providers or the official ES client. The real question is scope: a DSL builder is only valuable if it covers the query surface we actually use (bool/must/should, nested, function_score, aggregations, highlighting, suggesters). Anything it doesn't model forces raw array escape hatches, which erodes the abstraction's value.
Integration feasibility. Composer-installable, MIT-licensed, framework-agnostic PHP — so it drops into a Laravel app without migrations, config publishing, or a mandatory service provider. Nominal integration effort is low (hours, not weeks). The friction is not installation, it's the decision of where in our codebase the builder is allowed to appear and how we prevent it from leaking into domain code.
Technical risk. This is the dominant concern. At 11 stars and a 0.145 score, the package has effectively no community signal: likely a single maintainer, bus factor of one, no external contributors validating the API, and no visible production track record. The June 2025 release date is reassuring on freshness but tells us nothing about stability or versioning discipline (pre-1.0 semantics, breaking changes on minor bumps, and ES-version targeting all need verification). Elasticsearch's own DSL evolves across 7.x/8.x (type removal, query parameter changes), so an unmaintained builder becomes a source of silent misbehavior. Treat this as an "adopt with a fork plan," not "adopt and forget."
Key questions.
Stack fit. It complements, not replaces, the official Elasticsearch PHP client. The intended pattern is: builder produces the query array → our existing client executes it. Keep the builder behind our own thin SearchQueryBuilder interface so call sites depend on us, not on brokerexchange/elasticbuilder. That single indirection converts a supply-chain risk into a swappable implementation detail and lets us substitute spatie/elasticsearch-query-builder, ongr/elasticsearch-dsl, or a homegrown builder later without touching feature code.
Migration path. Use a strangler pattern. Introduce the builder for new query endpoints first; leave existing hand-rolled JSON DSL untouched until each query is deliberately migrated. Do not attempt a big-bang rewrite of search code — the risk/reward is poor and the package's coverage is unproven.
Compatibility. Validate against our actual cluster version before committing. 7.x vs. 8.x differences are material. Confirm PHP constraint compatibility with our Laravel version and run composer audit in the spike.
Sequencing.
Maintenance. Assume we own this de facto. Pin to an exact version, commit the lock, and budget a fork-and-patch path. Upgrades will not be driven by an active upstream community, so plan periodic manual reviews rather than relying on dependabot PRs alone.
Support. No vendor, no SLA — GitHub issues and source reading only. Onboarding requires developers comfortable reading the package source and the ES DSL directly. Acceptable for a search-savvy team; a liability for a team with shallow ES experience.
Scaling. Negligible runtime concern. Query construction is stateless and cheap; it scales horizontally with the app exactly as any pure-PHP helper does. Memory overhead is trivial relative to the ES round trip. No infrastructure impact.
Failure modes. The dangerous failure is silent: a builder that emits valid-but-wrong DSL (missing filter context, incorrect nesting, unescaped values) produces incorrect search results without an exception. Secondary risks are ES version drift producing rejected queries, breaking changes on minor version bumps, and eventual abandonment — mitigated by the internal interface and a pinned version. Low attack surface, but still include the package in dependency scanning.
Ramp-up. Low for developers already fluent in the ES DSL (the builder mirrors it); moderate for others, who will need to learn both the builder and the underlying DSL to debug. Documentation quality is unverified — assume source-reading is required and factor that into estimation.
Recommendation. Viable as an internal convenience layer if wrapped behind our own interface, pinned, and proven against our real query surface in a spike. Not advisable as a load-bearing dependency on core search without a fork contingency.
How can I help you explore Laravel packages today?