public function endBulkIndex() {
        if (!$this->connected) {
            return;
        }

		$index = $this->getIndex();

        try {
            foreach ($this->buffer as $type => $documents) {
                $index->getType($type)->addDocuments($documents);
                $index->refresh();
            }
        } catch (HttpException $ex) {
            $this->connected = false;

            // TODO LOG THIS ERROR
            \SS_Log::log($ex, \SS_Log::ERR);
        } catch (\Elastica\Exception\BulkException $be) {
            \SS_Log::log($be, \SS_Log::ERR);
            throw $be;
        }

		$this->buffered = false;
		$this->buffer = array();
	}