spatie/elasticsearch-query-builder
Lightweight fluent PHP query builder for Elasticsearch. Build searches, filters, and aggregations with a clean API, then execute via the official client. Designed to pair with Spatie’s search-string parser; covers common use cases and is easy to extend.
TermsAggregation, AvgAggregation) for dashboards, reporting, or real-time analytics.Adopt if:
Look elsewhere if:
match queries) and don’t justify abstraction.For Executives: "This package lets us build Elasticsearch queries in PHP with a clean, developer-friendly API—reducing errors, speeding up development, and making complex searches (like product filters or analytics) easier to implement. It’s like SQL’s ActiveRecord for Elasticsearch, cutting dev time and improving reliability. Low risk: open-source, MIT-licensed, and maintained by a trusted team."
For Engineering: *"We can replace manual JSON query construction with a type-safe, chainable builder that handles:
TermsAggregation, AvgAggregation).$results = (new Builder($client))
->index('products')
->addQuery(MatchQuery::create('name', 'laptop', fuzziness: 2))
->addAggregation(AvgAggregation::create('avg_price', 'price'))
->search();
```*
**Tradeoff**: Minimal learning curve (familiar to Laravel devs), but limited to supported query types. Ideal for 80% of use cases."*
How can I help you explore Laravel packages today?