Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Elasticsearch Dsl Laravel Package

handcraftedinthealps/elasticsearch-dsl

A fork of ongr/elasticsearch-dsl for building Elasticsearch queries in PHP with a fluent DSL. It extends support to a wider range of Symfony (3.4 through 7.x) and Elasticsearch versions, and powers the handcraftedinthealps Elasticsearch bundle.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. This is a query-construction library, not a search platform. It builds Elasticsearch request bodies — bool queries, filters, aggregations, sorting, nested fields, mappings — as typed PHP objects that serialize to arrays/JSON, which you then hand to a transport client. The integration surface is shallow and well-bounded: it owns no connections, no pooling, no retries, no cluster state, no schema lifecycle. For a Laravel application, that is the only surface worth evaluating. The "Symfony 5 support" framing in the description refers to the companion bundle's service wiring (handcraftedinthealps/elasticsearch-bundle), which is irrelevant in Laravel — treat the package as a framework-agnostic library in the ONGR\ElasticsearchDSL namespace and ignore the bundle. The practical TPM framing is: this replaces hand-assembled associative arrays in your search layer with testable, composable query objects. Nothing more.

Integration feasibility. High. Composer install, small dependency tree, no framework coupling, no container requirements, MIT license with no commercial obligation. It composes cleanly with elasticsearch/elasticsearch (official PHP client) or any Scout/custom driver, because the output is a plain array you can pass to whatever client you already use. A one-to-three day spike — build two or three representative production queries (a faceted catalog search, a nested-attribute filter, an aggregation-heavy admin search) and serialize them through your existing client — is sufficient to prove fit. The absence of Laravel-native service providers, facades, or config publishing is not a blocker; it just means you write the wiring and own it.

Technical risk. Three risks dominate, in order:

  1. Version ceiling. The matrix caps at Elasticsearch ^7.0 in the source table, though release notes show 8.x branches (8.0.0 through 8.3.0) with ES 8 support, runtime fields, kNN search, and parent aggregations. The documentation is inconsistent with the release history, which is itself a risk signal — you cannot trust the README to describe the current state. If your cluster is ES 8+, verify branch-to-cluster compatibility empirically in the spike rather than trusting the table.
  2. Abandonment / fork-of-a-fork. 21 stars, 0 dependents, a fork of ongr-io/elasticsearch-dsl that is itself a fork lineage. Recent releases (June 2025) and active maintainers (alexander-schranz, hkulekci) are encouraging, but the dependent count means you are effectively the only consumer shaping its roadmap. There is no downstream ecosystem to surface regressions for you.
  3. Coverage gaps. A DSL lags the Elasticsearch API. New query types, new aggregation parameters, and new ES versions will land in the official client before they land here. You will occasionally drop to raw arrays for features the DSL has not modeled — plan for that escape hatch rather than treating it as a failure.

Key questions for the spike.

  • Which exact Elasticsearch version is in production, and which package branch maps to it — verified by running real queries, not by reading the table?
  • Does the DSL cover the specific query constructs the roadmap needs (kNN/vector search, runtime fields, nested aggregations, terms_set, parent aggregations)? Which ones fall back to raw arrays?
  • Who owns the adapter, and can we patch or vendor the package if a fix is needed upstream and not merged?
  • What is the blast radius if the package is abandoned — how many call sites touch it, and how long would a replacement take?
  • Does the official elasticsearch-php client version we need coexist with the DSL's serialization assumptions?

Integration Approach

Stack fit. Laravel + PHP 8.x + elasticsearch/elasticsearch + this DSL is a coherent combination. The DSL sits between your application's search services and the client, converting query objects to arrays the client already understands. It has no opinion on HTTP transport, credentials, hosts, or connection pools — those stay with the official client and your existing configuration. In a Laravel context, register the client as a singleton in a service provider, inject it into repository/search-service classes, and keep the DSL confined to those classes. Do not let DSL objects leak into controllers, models, or API resources; the boundary should be "search service accepts domain criteria, returns hydrated results."

Migration path. Adopt incrementally rather than rewriting the search layer. Sequence:

  1. Introduce the package as a dependency without changing any query.
  2. Wrap the DSL behind an internal interface — for example SearchQueryBuilder — with one implementation that delegates to the DSL and one that returns raw arrays. This is the single most important decision: it caps the cost of abandonment at one class.
  3. Port one non-critical query first (an admin filter or a low-traffic listing) and compare serialized output byte-for-byte against the existing hand-built array. Elasticsearch is forgiving of key order but not of shape; a diff here catches subtle mistakes early.
  4. Port the complex queries next — the ones with nested bool logic, multi-level aggregations, or repeated filter fragments — because that is where the DSL earns its cost.
  5. Leave simple one-line match queries alone. Converting them adds indirection with no payoff.

Compatibility. Two axes matter. First, package branch to Elasticsearch version: pin explicitly (e.g. ^7.5 for ES 7, the 8.x line for ES 8) and record the mapping in your dependency notes, because the README table and the release history disagree. Second, PHP and Laravel: PHP 8 support landed early and the package is not framework-coupled, so Laravel version is effectively irrelevant — but verify against your PHP minor version, since a library this small will not have been tested against every combination. Run composer why-not and check the lock file for any transitive constraint that pins an older symfony/* component even though you are not using the bundle.

Sequencing. Dependency and adapter → one low-risk query in production → complex queries → delete the dead raw-array code paths. Keep the raw-array implementation available for at least one release cycle after full migration so rollback is a config flag, not a revert. Budget the spike as a timeboxed investigation with a written go/no-go, not as an open-ended commitment.

Operational Impact

Maintenance. Low ongoing code maintenance, moderate dependency maintenance. The package is small and stable; the API surface you use will change rarely. The real cost is upgrade coupling: when Elasticsearch ships a new minor version, you wait on this package (and its handful of contributors) to model the new query types, or you drop to raw arrays for that feature. Budget a recurring line item — a few days per year — for tracking releases and validating against cluster upgrades. Assign explicit ownership; an unowned fork dependency is the failure mode that bites eighteen months later.

Support. No commercial support, no SLA, no vendor to escalate to. Support is GitHub issues and the goodwill of two or three maintainers who are also maintaining the companion bundle. That is acceptable for a query-construction utility where a workaround always exists (raw arrays) and unacceptable for anything on the critical path with no fallback. The MIT license means you can fork and patch, but that converts a dependency into a maintenance obligation — decide in advance whether your team would actually do that, or whether you would instead rip the adapter out and go back to arrays.

Scaling. Effectively unlimited in the dimensions that matter. Query construction is CPU-trivial per request; the DSL adds object instantiation and array serialization, which is noise next to network round-trips and Elasticsearch execution time. There is no shared state, no connection pool, no cache to warm. It scales horizontally with your PHP workers by construction. The scaling constraint is Elasticsearch itself — shard sizing, query cost, aggregation memory — and this package neither helps nor hinders that. Do not let anyone position DSL adoption as a performance initiative; it is a maintainability initiative.

Failure modes. Rank them:

  • Silent shape drift. The DSL serializes to a slightly different query shape than your hand-built array — a filter that becomes a must, a minimum_should_match that changes semantics — and results change without errors. Mitigated by output-diffing during migration and by golden-file tests against real cluster responses.
  • Version mismatch. Package branch and cluster version diverge, producing either unsupported query types or silently ignored parameters. Mitigated by pinning and by a smoke test in CI against a containerized cluster of the production version.
  • Coverage gap discovered mid-feature. A roadmap feature needs a query type the DSL has not modeled, forcing a raw-array escape hatch and an inconsistent codebase. Mitigated by auditing the roadmap against DSL coverage before committing.
  • Abandonment. No releases for a year, then an Elasticsearch major version you cannot adopt. Mitigated by the adapter boundary — the exit is deleting one class.
  • Maintainer bus factor. One or two people carry the fork. Nothing you can do except keep the exit open.

Ramp-up. Low for anyone who already knows Elasticsearch's query DSL — the object API mirrors the JSON structure closely, so the learning curve is mostly discovering which class maps to which clause, and the bundled docs cover that. A mid-level PHP engineer is productive in half a day and fluent in a week. The harder ramp is for engineers who do not know Elasticsearch: the library gives them a fluent API that makes it easy to construct queries without understanding scoring, analyzers, or aggregation cost. That is a genuine hazard — it lowers the barrier to writing expensive queries. Pair adoption with a short internal note on query cost and a review checklist for aggregation-heavy changes. No Laravel-specific training is needed because there is no Laravel-specific surface; the wiring you write is your own and should be documented in the team's service-provider conventions.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator