0.1.8
🚀 Add ability to change available indices by implementing custom IndicesService
(extend existing implementation or use IndicesServiceContract
.
1. Edit lelastico.php config
'service' => MyOwnIndicesService::class,
2. Change the implementation
namespace App\ElasticSearch;
use App\Storage\ConfigStorageContract;
use App\Storage\ISConfigStorage;
use Illuminate\Contracts\Config\Repository;
use Lelastico\IndicesService;
class ISIndicesService extends IndicesService
{
private ISConfigStorage $configStorage;
public function __construct(Repository $configRepository, ISConfigStorage $configStorage)
{
parent::__construct($configRepository);
$this->configStorage = $configStorage;
}
public function getAvailableIndices(): array
{
$groupedIndices = parent::getAvailableIndices();
$baseIndices = $groupedIndices['base'];
if ($this->configStorage->getDataSource() === ConfigStorageContract::IS2_DATA_STORE) {
return array_merge($baseIndices, $groupedIndices['is2']);
}
return $baseIndices;
}
}