- What is designmynight/laravel-elasticsearch used for?
- It lets Laravel applications register Elasticsearch as a database connection and run Eloquent-style queries that return hydrated model instances. It supports query, filter, and postFilter types, geo searches, complex aggregations, and the scroll API for large result sets. It is a deep extension of Laravel's database and Eloquent layers rather than a thin Elasticsearch SDK wrapper.
- How do I install and configure laravel-elasticsearch in a Laravel app?
- Add the Composer package, then add an elasticsearch connection to config/database.php with the driver, host, port, database index, and optional username, password, and suffix. Override newEloquentBuilder() and newBaseQueryBuilder() on your base Model so the package builders are used for the Elasticsearch connection. After that, searches on models using that connection can return Eloquent models and aggregations.
- Does this package support Laravel 12?
- Release notes show a v12 line, from v12.0.0 through v12.0.4, supporting Laravel 12, including fixes for Laravel signature drift and createBlueprint() restoration. The README compatibility table is stale and maps older package versions to Elasticsearch 5.x through 7.0. Check the release notes and Composer constraints before upgrading, because Laravel major upgrades will likely require a matching package release.
- Which Elasticsearch versions does laravel-elasticsearch support?
- The README table maps package versions 4, 5, and 6 to Elasticsearch 5.x through 7.0, but that table is stale. Release notes show a v12 line for Laravel 12 and older v6, v7, and v8 lines, but there is no published statement mapping the current package line to Elasticsearch 8.x or 9.x or to a specific elasticsearch-php client major. Treat version compatibility as the highest-risk unknown and verify it before committing.
- Can I get Eloquent models back from Elasticsearch queries?
- Yes, returning hydrated Eloquent model instances is the main architectural value of this package. Views, API resources, policies, and serializers written against models can often be reused for search results instead of handling raw arrays. This requires the base Model overrides, and mapping design, analyzers, and scoring remain Elasticsearch concerns that the Eloquent-style abstraction does not hide.
- How do the index lifecycle and mapping commands work?
- The package ships Artisan commands including make:mapping, migrate:mappings, index:swap, index:copy, index:rollback, index:list, and index:remove. Together with its alias-per-index convention, these let you wire index lifecycle into CI/CD rather than running hand-written curl scripts. This is one of the strongest operational features for reducing deployment risk.
- How do I retrieve large result sets with laravel-elasticsearch?
- Use the Elasticsearch scroll API, which the package exposes as a Generator so you can iterate over large result sets lazily. This avoids loading everything into memory at once. The package also supports bulk insert and delete-by-query for write-path work.
- Can I run aggregations and geo searches with this package?
- Yes, it supports complex and nested aggregations, geo distance and bounds searches, and query, filter, and postFilter query types. You can build these through Elasticsearch-shaped query builder calls while still receiving model instances where appropriate. You still need to design mappings and analyzers correctly for the searches and aggregations you want.
- Is laravel-elasticsearch production-ready and well maintained?
- It appears to be used in production by its maintainer, DesignMyNight, and release notes reference internal incidents, which suggests real-world hardening. However, it has about 30 stars and 0 recorded dependents, no vendor SLA, and effectively single-organization ownership. Coupling to Laravel internals creates an upgrade tax, so review changelogs even for minor upgrades because breaking changes have occurred, such as a QueryException namespace move and new BulkInsertQueryException.
- What are the alternatives and caveats compared with Laravel Scout or the official Elasticsearch client?
- Alternatives include the official elasticsearch-php client, Laravel Scout with an Elasticsearch driver, or hand-rolled read models. Choose this package when you specifically want Eloquent-shaped queries and hydrated models as a read path over Elasticsearch. Be careful with semantic leakage: where('field', 'like', ...) does not behave like SQL, and query-builder ordering does not imply relevance ordering. If you need guaranteed Elasticsearch 8.x or 9.x support or broad community troubleshooting, validate compatibility or consider a more actively adopted option.