/**
* Check if $exception is a bulk response exception that just contains
* document is missing failures.
*
* @param ResponseException $exception exception to check
* @param callback|null $logCallback Callback in which to do some logging.
* Callback will be passed the id of the missing document.
* @return bool
*/
protected function bulkResponseExceptionIsJustDocumentMissing(ResponseException $exception, $logCallback = null)
{
$justDocumentMissing = true;
foreach ($exception->getResponseSet()->getBulkResponses() as $bulkResponse) {
if (!$bulkResponse->hasError()) {
continue;
}
$pos = strpos($bulkResponse->getError(), 'DocumentMissingException');
if ($pos === false) {
$justDocumentMissing = false;
} elseif ($logCallback) {
// This is generally not an error but we should
// log it to see how many we get
$id = $bulkResponse->getAction()->getData()->getId();
call_user_func($logCallback, $id);
}
}
return $justDocumentMissing;
}