Skip to content

Instantly share code, notes, and snippets.

@wazum
Created July 30, 2022 12:27
Show Gist options
  • Save wazum/30c1a02894c9e1ad3cb5c619a28e4528 to your computer and use it in GitHub Desktop.
Save wazum/30c1a02894c9e1ad3cb5c619a28e4528 to your computer and use it in GitHub Desktop.
My Batch Handler Solr example
<?php
$documents = [];
foreach ($jobs as [$job, $ack]) {
try {
$documents[] = $this->solrService->createDocument($job->something());
$ack->ack($job);
} catch (\Exception $e) {
$ack->nack($e);
}
}
// Index documents in Solr using Solarium PHP client
$update->addDocuments($documents);
$update->addCommit();
$client->update($update);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment