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 Dsl Laravel Package

ongr/elasticsearch-dsl

Object-oriented Elasticsearch query builder for PHP. Build searches, filters, aggregations and more with a DSL, then export to arrays for elasticsearch-php or ONGR ElasticsearchBundle. Supports Elasticsearch 5/6/7 via versioned releases.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Search & Discovery Features: Enables advanced search capabilities (e.g., faceted search, aggregations, relevance tuning) for products requiring Elasticsearch-powered search (e.g., e-commerce, content platforms, analytics dashboards).
  • Roadmap for Scalable Search: Justifies investing in Elasticsearch as a backend for search-heavy applications, reducing reliance on slower SQL-based full-text search (e.g., PostgreSQL tsvector).
  • Build vs. Buy: Avoids reinventing Elasticsearch query logic, saving engineering time. The package abstracts low-level Elasticsearch syntax into a PHP-friendly DSL, reducing cognitive load for developers.
  • Use Cases:
    • E-commerce: Product filtering, autocomplete, and recommendation engines.
    • Content Platforms: Search-as-you-type, tag-based navigation, and analytics.
    • Log/Event Analysis: Real-time aggregations (e.g., cardinality, stats) for observability tools.
    • Hybrid Search: Combining structured (SQL) and unstructured (Elasticsearch) data for unified queries.

When to Consider This Package

  • Adopt if:

    • Your PHP application requires complex Elasticsearch queries (e.g., nested aggregations, function scoring, compound queries) but lacks in-house Elasticsearch expertise.
    • You’re using Symfony or Laravel and want seamless integration with elasticsearch-php without framework-specific bloat.
    • Your search needs aggregations (e.g., stats, cardinality, nested buckets) for analytics or UX features like "popular tags."
    • You prioritize developer productivity: The DSL reduces boilerplate for constructing Elasticsearch queries from ~50 lines of JSON to ~10 lines of PHP.
    • Your team prefers type safety and IDE autocompletion over raw JSON query strings.
  • Look Elsewhere if:

    • You need real-time indexing or sub-second latency: This package is for query building, not core Elasticsearch operations (use elasticsearch-php directly or Elasticsearch’s native APIs).
    • Your use case is simple keyword search: Laravel Scout or PostgreSQL full-text search may suffice.
    • You’re locked into Elasticsearch 1.x–5.x: This package drops support for versions <6.0.
    • Your stack is non-PHP: Use Elasticsearch’s native REST API or language-specific clients (e.g., Python’s elasticsearch-dsl-py).
    • You require custom Elasticsearch features not covered by the DSL (e.g., ML inference, graph queries). Extend the package or use raw queries.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us build sophisticated search features—like product recommendations, dynamic filtering, or real-time analytics—without hiring Elasticsearch specialists. For example, we can add ‘frequently bought together’ sections or ‘search-as-you-type’ in weeks, not months. It’s a drop-in solution that works with our existing PHP stack, reducing technical debt while enabling features that drive engagement and revenue. The MIT license and active community mean low risk."

Key Outcomes:

  • Faster time-to-market for search features.
  • Lower engineering overhead vs. custom solutions.
  • Scalable infrastructure for growth (e.g., handling 10x more search queries).

For Engineering:

"This is a query builder for Elasticsearch that turns verbose JSON into clean PHP code. For example, instead of writing this:

{
  "query": {
    "function_score": {
      "query": { "match_all": {} },
      "functions": [ { "weight": 2, "filter": { "range": { "price": { "gte": 10 } } } } ]
    }
  }
}

You write this:

$functionScoreQuery = new FunctionScoreQuery(new MatchAllQuery());
$functionScoreQuery->addWeightFunction(2, new RangeQuery('price', ['gte' => 10]));

Benefits:

  • No more JSON syntax errors: IDE autocompletion and type hints catch mistakes early.
  • Framework-agnostic: Works in Laravel/Symfony or vanilla PHP.
  • Full Elasticsearch coverage: Supports aggregations, compound queries, and scoring functions.
  • Future-proof: Actively maintained (last release: 2023) with Elasticsearch 7.x+ support.

Trade-offs:

  • Adds a dependency, but it’s lightweight (~1MB) and MIT-licensed.
  • For edge cases, you can still drop to raw Elasticsearch queries.

Recommendation: Use this for all new Elasticsearch features. Pair it with elasticsearch-php for indexing and the ElasticsearchBundle if using Symfony."*

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
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