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 Query Builder Laravel Package

spatie/elasticsearch-query-builder

A lightweight, fluent PHP API for building and executing ElasticSearch queries. Chain queries and aggregations, then call search(). Built for Spatie's search-string-parser but flexible enough to cover most common use cases.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for the search-query layer: Adopt a small MIT-licensed query builder instead of hand-rolling Elasticsearch query arrays. This is not a search platform purchase; it is a developer-productivity decision that can reduce custom DSL code and shorten delivery time for common search features.
  • Search roadmap sequencing: Enables PMs to prioritize user-facing relevance features—fuzzy matching, multi-field search, geo filtering, nested content search, aggregations/facets, collapsed/deduplicated results—without waiting for a bespoke query abstraction.
  • Feature scoping and MVP definition: Useful when the product needs common Elasticsearch capabilities quickly: catalog filters, range filters, term/terms filters, wildcard/prefix-style search, bool combinations, sorting, pagination, field selection, and multi-search for dashboards.
  • Use-case validation: Strong fit for product search, admin/internal search, content search, geo-aware search, nested comment/review search with inner hits, percolate-style alerting, and grouped/collapsed results such as “top posts per user.”
  • Standardization decision: A fluent PHP API creates consistent query payloads across teams and makes query construction easier to review and test via getPayload() before execution.
  • Risk and ownership decision: Because it is lightweight, MIT, and forkable, PMs can treat it as a tactical dependency rather than a strategic platform bet. The team still owns Elasticsearch infrastructure, index mappings, relevance tuning, and data pipelines.

When to Consider This Package

Consider it when:

  • The team is on PHP/Laravel and already uses the official elasticsearch/elasticsearch client.
  • The product needs common Elasticsearch query DSL features—bool queries, match/multi-match, term/terms, range, fuzzy, nested, geo-shape, wildcard, aggregations, sorts, pagination, collapse, and multi-search.
  • Engineering wants a thin, readable abstraction over raw Elasticsearch arrays without adopting a full search framework.
  • The team values the Spatie ecosystem, MIT licensing, changelog/release hygiene, and the option to fork or contribute missing features.
  • The search surface is moderately complex but not exotic: product catalogs, content search, admin search, geo filters, faceted navigation, nested data, or dashboard multi-search.
  • A short spike can validate version compatibility and coverage against the planned query set.

Look elsewhere when:

  • The roadmap requires vector/kNN search, semantic/hybrid search, advanced relevance tuning, runtime fields, transforms, ESQL, or complex aggregation pipelines not covered by the package.
  • The organization requires a vendor-supported SDK with broad official coverage and SLAs, or procurement treats low dependent count as a blocker.
  • The team already has a mature in-house query abstraction or is comfortable maintaining raw Elasticsearch payloads.
  • The product needs a full search platform—managed search UI, analytics, synonym management, merchandising, A/B testing, or index lifecycle orchestration. This package builds queries; it does not run or govern search.
  • The stack is not PHP, or the team expects Laravel Scout/Eloquent-style model integration rather than direct Elasticsearch client usage.

How to Pitch It (Stakeholders)

Executive summary: spatie/elasticsearch-query-builder is a low-cost, MIT-licensed PHP package that lets engineering build Elasticsearch queries through a fluent API instead of hand-written arrays. It can accelerate delivery of common search features—filters, facets, fuzzy matching, geo search, nested search, sorting, pagination, and multi-search—while preserving direct access to Elasticsearch. It is not a search platform and does not replace infrastructure, indexing, or relevance ownership. The main adoption risk is low dependent count and limited scope; mitigate with a short engineering spike and a fork-friendly posture.

For engineering: It is a lightweight wrapper around the official Elasticsearch PHP client, with composable query and aggregation classes, bool-query chaining, payload inspection via getPayload(), multi-search support, collapse, and nested inner hits. It reduces boilerplate and standardizes query construction, but the team should confirm coverage against the planned query types and pin compatible versions.

For product/finance: No license fee, small integration footprint, and potential sprint savings versus building a custom query layer. The real cost is Elasticsearch operations, index design, relevance tuning, and dependency maintenance—not the package itself.

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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings