$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("MagentoIndexerModelIndexerCollectionFactory");
$indexerFactory = $objectManager->get("MagentoIndexerModelIndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id) {
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
}