Weave Code
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

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Search Functionality Expansion: Enables building complex, type-safe Elasticsearch queries without manual JSON construction, reducing developer errors and improving maintainability.
  • Roadmap for Analytics & Insights: Supports aggregations (e.g., TermsAggregation, AvgAggregation) for dashboards, reporting, or real-time analytics.
  • Build vs. Buy: Avoids reinventing a query builder wheel, leveraging a battle-tested, open-source solution with active maintenance.
  • Use Cases:
    • Full-text search (e.g., e-commerce product catalogs, content platforms).
    • Geospatial queries (e.g., location-based services).
    • Nested data queries (e.g., comments, reviews, or hierarchical structures).
    • Advanced filtering (e.g., price ranges, date ranges, boolean logic).
    • Multi-search for batch operations (e.g., syncing data across indices).

When to Consider This Package

  • Adopt if:

    • Your PHP/Laravel app relies on Elasticsearch for search/analytics.
    • You need a fluent, type-safe API to construct queries (vs. raw JSON).
    • Your team lacks deep Elasticsearch expertise but requires complex queries (e.g., aggregations, nested queries).
    • You want to reduce boilerplate and improve query readability/maintainability.
    • Your use case aligns with supported query types (e.g., no need for custom DSL features).
  • Look elsewhere if:

    • You require unsupported Elasticsearch features (e.g., rare query types, advanced scripting).
    • Your team prefers low-level control over query construction (e.g., for performance tuning).
    • You’re using Elasticsearch v7 (requires v1 of this package).
    • Your search needs are simple (e.g., basic match queries) and don’t justify abstraction.

How to Pitch It (Stakeholders)

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:

  • Complex queries (bool logic, nested data, geospatial) via fluent methods.
  • Aggregations for dashboards/reports (e.g., TermsAggregation, AvgAggregation).
  • Multi-search for batch operations. It integrates seamlessly with Laravel and the Elasticsearch PHP client, reducing bugs and improving maintainability. Example:
$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."*
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai