/** * Bulk Delete a collection of Models. * * @param array|collection $collection * * @return mixed */ public function bulkDelete($collection = []) { $params = []; $defaultIndex = $this->connection->getDefaultIndex(); foreach ($collection as $item) { $modelIndex = $item->getDocumentIndex(); $params['body'][] = ['delete' => ['_id' => $item->getKey(), '_type' => $item->getDocumentType(), '_index' => $modelIndex ? $modelIndex : $defaultIndex]]; } return $this->connection->bulkStatement($params); }