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

Elasticlens Laravel Package

pdphilip/elasticlens

ElasticLens brings Elasticsearch power to Laravel models with Eloquent-style queries. Define your own index models, mappings, and schema—no black box. Run phrase/term searches, filters, embedded fields, geo distance sorting, and pagination with fluent, readable APIs.

View on GitHub
Deep Wiki
Context7
v4.0.0

This release is compatible with Laravel 10, 11 & 12

The engine has been rewritten from the ground up. The core indexing, observer, and build systems were gutted and rebuilt with cleaner internals, typed signatures, and proper error boundaries. The package now has a full test suite (unit + integration) running against a real Elasticsearch instance in CI - something that didn't exist before.

Full documentation now lives at elasticlens.pdphilip.com

What's New

  • viaIndex()->get() now returns base models directly - no more getBase() needed
  • Conditional Indexing - control which records get indexed via excludeIndex()
  • Soft Delete Support - configurable globally or per index model
  • Full test suite with Elasticsearch service container in CI
  • Requires pdphilip/omniterm: ^2

Breaking Changes

  • viaIndex()->get() returns base model collection (was index model collection; use ->get() directly instead of ->getBase())
  • getBase() and paginateBase() still work but are no longer necessary for the default case

See the upgrade guide for migration details.

v3.1.2

This release is compatible with Laravel 10, 11 & 12

What's Changed

  • Bug fix: Fixed typo in removeIndex() method and ensure bool is returned

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.1.2...v3.1.2

v3.1.1

This release is compatible with Laravel 10, 11 & 12

What's changed

  • New Helper: IndexableBuild::buildErrorsQuery($indexModel) - returns a query prepared for failed builds of an index-model
$buildErrors = IndexableBuild::buildErrorsQuery(IndexedUser::class)->get();


  • Bug fix: ensure array for internal state_data on IndexableBuild

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.1.0...v3.1.1

v3.1.0

This release is compatible with Laravel 10, 11 & 12

What's Changed

  1. Chunk rate for the migration command can now be explicitly set in the Index-Model with the protected int $buildChunkRate property
class IndexedUser extends IndexModel
{
    protected int $buildChunkRate = 2000;



  1. Migrations are validated before running the lens:migration and lens:build commands. If there are any migration errors in the migrationMap() method then it will be shown - via issue #6

PRs

New Contributors

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.0.3...v3.1.0

v3.0.3

What's Changed

  • paginateBase() bug. Fixed issue where subsequent paging returned data (items) as non-sequential arrays.

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.0.2...v3.0.3

v3.0.2

What's Changed

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.0.1...v3.0.2

v3.0.1

This release is compatible with Laravel 10, 11 & 12

What's changed

New features

  • Skippable models via optional excludeIndex(): bool method in your base model
  • Delete an index from your model instance: $user->removeIndex()
  • New Index Model method: IndexedUser::whereIndexBuilds()->get() - returns index build logs for model
  • New Index Model method: IndexedUser::whereFailedIndexBuilds()->get() - returns failed index build logs for model
  • New Index Model method: IndexedUser::whereMigrations()->get() - returns migration logs for model
  • New Index Model method: IndexedUser::whereMigrationErrors()->get() - returns failed migrations for model
  • New index Model method: IndexedUser::lensHealth() - returns an array of the index health

Fixes

  • v5 compatibility fixes with bulk insert and saving without refresh
  • Indexable trait search() runs searchPhrasePrefix() under the hood
  • paginateBase() honors current path

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v3.0.0...v3.0.1

v3.0.0

This is an updated dependency release compatible with:

  • Laravel 10/11/12
  • laravel-elasticsearch package v5

What's Changed

New Contributors

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v2.0.1...v3.0.0

v2.0.1

Bug fix: lens:make command fixed to properly accommodate Domain spaced setups

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v2.0.0...v2.0.1

v2.0.0

Version 2 introduces breaking changes to support multiple model namespace mappings, providing flexibility for domain-driven architecture. This update allows the use of multiple model sources.

The elasticlens.php config file now requires the following structure:

'namespaces' => [
    'App\Models' => 'App\Models\Indexes',
],

'index_paths' => [
    'app/Models/Indexes/' => 'App\Models\Indexes',
],










• The namespaces key maps models to their respective index namespaces. • The index_paths key maps file paths to the corresponding index namespaces.

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v1.3.1...v2.0.0

v1.3.1
  • Bug fix: Bulk insert was not writing to the IndexableBuild model correctly
  • Better IDE support for IndexModel macros, ie: getBase(), asBase() & paginateBase()

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v1.3.0...v1.3.1

v1.3.0

Changes

  • Renamed asModel() to asBase()
  • Renamed paginateModels() to paginateBase()
  • Added convenience method getBase() that can replace ....->get()->asBase()

Dependency update to use laravel-elasticsearch ^v4.4

Full Changelog: https://github.com/pdphilip/elasticlens/compare/v1.2.2...v1.3.0

v1.1.0

New Feature

Bulk index (re)builder with:

php artisan lens:build {model}













v1.0.0

ElasticLens v1.0.0

ElasticLens is proud to announce its initial release. This powerful and flexible Laravel package is designed to allow developers to search their Laravel models with the convenience of Eloquent and the power of Elasticsearch.

Features

  • Eloquent Integration: Easily index and search your Laravel models with Elasticsearch.
  • Automatic Indexing: Models are automatically indexed when created, updated, or deleted.
  • Custom Mappings: Define custom Elasticsearch mappings for your models.
  • Flexible Searching: Perform simple searches or complex queries using Elasticsearch's full-text search capabilities.
  • Query Builder: Intuitive query builder for constructing complex Elasticsearch queries.
  • Aggregations: Support for Elasticsearch aggregations to perform complex data analysis.
  • Pagination: Built-in support for paginating search results.
  • Console Commands: Artisan commands for managing indices and performing bulk operations.
  • Model Observers: Customizable model observation for index builds.

Installation

You can install ElasticLens via Composer:

composer require pdphilip/elasticlens

Then run install:

php artisan lens:install














Documentation

For detailed documentation and advanced usage, please refer to the GitHub repository.

Feedback and Contributions

Feedback, bug reports, and contributions are highly appreciated. Users and developers are encouraged to open issues or submit pull requests on the GitHub repository. The ElasticLens community looks forward to collaborating and improving the package together.

Happy searching with ElasticLens!

v4.0.1

Added

  • firstIndex() and firstBase() methods on LensBuilder
  • lens:errors {model} command to inspect failed index builds with paginated output
  • BuildsIndex shared trait for bulk building (used by lens:build and lens:migrate)
  • 24 new LensBuilder integration tests covering all empty and populated query paths

Fixed

  • viaIndex()->get() TypeError on empty results (return type mismatch: Collection vs ElasticCollection)
  • viaIndex()->first() calling asBase() on an already-converted base model
  • first() / firstBase() now correctly disable returnAsBase before delegating to parent (same pattern as paginateAsIndex)
  • updated_at no longer leaks into index documents when not defined in the field map ($timestamps = false on IndexModel)

Changed

  • lens:migrate build step now uses bulk insert (was one-at-a-time RecordBuilder::build())
  • lens:build refactored to use shared BuildsIndex trait
  • Removed stale PHPStan ignore rule for Blade view() calls in Commands
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport