Ré indexer Search API par le code

Ré indexer tout Search API 

use Drupal\search_api\Utility\CommandHelper;

$command_helper = new CommandHelper(\Drupal::entityTypeManager(), \Drupal::moduleHandler(), 'dt');
$command_helper->setLogger(\Drupal::logger('search_api'));
$command_helper->resetTrackerCommand();
$command_helper->indexItemsToIndexCommand();

Ré indexer un id spécifique

ici notre id sera eleasticsearch_index

use Drupal\search_api\Utility\CommandHelper;

$command_helper = new CommandHelper(\Drupal::entityTypeManager(), \Drupal::moduleHandler(), 'dt');
$command_helper->setLogger(\Drupal::logger('search_api'));
$command_helper->resetTrackerCommand(['eleasticsearch_index']);
$command_helper->indexItemsToIndexCommand(['eleasticsearch_index']);