Skip to content

Build and Migration States

ElasticLens provides built-in Elasticsearch models to track the state of your index builds and migrations.

The IndexableBuild and IndexableMigrationLog models are Elasticsearch models that you can access directly using the Laravel-Elasticsearch package.

ElasticLens includes a built-in IndexableBuild model that allows you to monitor and track the state of your index builds.

This model records the status of each index build, providing you with insights into the indexing process.

Fields
/**
* PDPhilip\ElasticLens\Models\IndexableBuild
******Fields*******
* @property string $model // The base model being indexed.
* @property string $model_id // The ID of the base model.
* @property string $index_model // The corresponding index model.
* @property string $last_source // The last source of the build state.
* @property IndexableStateType $state // The current state of the index build.
* @property array $state_data // Additional data related to the build state.
* @property array $logs // Logs of the indexing process.
* @property Carbon $created_at // Timestamp of when the build state was created.
* @property Carbon $updated_at // Timestamp of the last update to the build state.
******Attributes*******
* @property-read string $state_name // The name of the current state.
* @property-read string $state_color // The color associated with the current state.
**/

Built-in methods include:

use PDPhilip\ElasticLens\Models\IndexableBuild;
IndexableBuild::returnState($model, $modelId, $indexModel);
IndexableBuild::countModelErrors($indexModel);
IndexableBuild::countModelRecords($indexModel);

ElasticLens includes a built-in IndexableMigrationLog model for monitoring and tracking the state of index migrations.

This model logs each migration related to an Index Model.

Fields
/**
* PDPhilip\ElasticLens\Models\IndexableBuild
******Fields*******
* @property string $index_model // The migrated Index Model
* @property IndexableMigrationLogState $state // State of the migration
* @property array $map // Migration map that was passed to Elasticsearch.
* @property int $version_major // Major version of the indexing process.
* @property int $version_minor // Minor version of the indexing process.
* @property Carbon $created_at // Timestamp of when the migration was created.
******Attributes*******
* @property-read string $version // Parsed version ex v2.03
* @property-read string $state_name // Current state name.
* @property-read string $state_color // Color representing the current state..
**/

Built-in methods include:

use PDPhilip\ElasticLens\Models\IndexableMigrationLog;
IndexableMigrationLog::getLatestVersion($indexModel);
IndexableMigrationLog::getLatestMigration($indexModel);