designmynight/laravel-elasticsearch
Laravel package that lets you query Elasticsearch with Eloquent-style builders and get model instances back. Supports query/filter/postFilter, geo search, complex aggregations, and the scroll API for large result sets.
Strengths:
where(), aggregation(), geo filters) without learning Elasticsearch’s native DSL. This reduces cognitive load and accelerates development.create, read, update, and delete operations (including bulk deletes via deleteByQuery), making it viable for primary data storage in read-heavy or hybrid architectures.make:mapping, migrate:mappings) streamline schema management and zero-downtime index swaps, which is essential for production-grade deployments.Limitations:
Laravel Compatibility:
newEloquentBuilder() and newBaseQueryBuilder() in a base model class (or use traits).config/database.php).Elasticsearch Compatibility:
Dependency Risks:
elasticsearch/elasticsearch PHP client, which is actively maintained but may introduce breaking changes if Elasticsearch upgrades.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Schema Drift | High | Use make:mapping CLI to version-control mappings and enforce CI/CD checks for index consistency. |
| Performance Bottlenecks | Medium | Benchmark query performance under load; use the scroll API for large datasets. |
| Data Consistency | High | Avoid using Elasticsearch as a primary store for mutable data. Use it for read replicas or event-sourced projections. |
| Elasticsearch Version Lock | High | Pin Elasticsearch cluster version to match the package version; test upgrades thoroughly. |
| Custom Query Limitations | Medium | Extend the package or use raw Elasticsearch queries via the underlying client when needed. |
| Cold Start Latency | Medium | Pre-warm indices or use Elasticsearch’s warmers for aggregations. |
| Multi-Region Deployments | High | Configure Elasticsearch client for cross-cluster routing if using distributed clusters. |
Data Model:
--swap flag)?Performance:
composite aggregations for deep pagination.Operational Overhead:
Development Workflow:
Cost:
Alternatives:
pg_search or full-text search suffice for simpler use cases?Best For:
Stack Conflicts:
Assessment Phase:
Proof of Concept:
Product) with Elasticsearch.Incremental Rollout:
create, update) if using Elasticsearch as a primary store.Deprecation Strategy:
Laravel:
whereNot).Elasticsearch:
type → parent_type), but custom mappings may break across major ES versions.Dependencies:
elasticsearch/elasticsearch PHP client (v7+ for ES 7.x).How can I help you explore Laravel packages today?