protected function addDocumentsToSolrIndex(array $documents)
    {
        $documentsAdded = false;

        if (!count($documents)) {
            return $documentsAdded;
        }

        try {
            $this->logger->log(SolrLogManager::INFO, 'Adding ' . count($documents) . ' documents.', $documents);

            // chunk adds by 20
            $documentChunks = array_chunk($documents, 20);
            foreach ($documentChunks as $documentChunk) {
                $response = $this->solrConnection->getWriteService()->addDocuments($documentChunk);
                if ($response->getHttpStatus() != 200) {
                    throw new \RuntimeException('Solr Request failed.', 1331834983);
                }
            }

            $documentsAdded = true;
        } catch (\Exception $e) {
            $this->logger->log(SolrLogManager::ERROR, $e->getMessage() . ' Error code: ' . $e->getCode());

            if ($this->configuration->getLoggingExceptions()) {
                $this->logger->log(SolrLogManager::ERROR, 'Exception while adding documents', [$e->__toString()]);
            }
        }

        return $documentsAdded;
    }
protected function addDocumentsToSolrIndex(array $documents)
    {
        $documentsAdded = false;

        if (!count($documents)) {
            return $documentsAdded;
        }

        try {
            $this->logger->log(SolrLogManager::INFO, 'Adding ' . count($documents) . ' documents.', $documents);

            // chunk adds by 20
            $documentChunks = array_chunk($documents, 20);
            foreach ($documentChunks as $documentChunk) {
                $response = $this->solrConnection->getWriteService()->addDocuments($documentChunk);
                if ($response->getHttpStatus() != 200) {
                    throw new \RuntimeException('Solr Request failed.', 1331834983);
                }
            }

            $documentsAdded = true;
        } catch (\Exception $e) {
            $this->logger->log(SolrLogManager::ERROR, $e->getMessage() . ' Error code: ' . $e->getCode());

            if ($this->configuration->getLoggingExceptions()) {
                $this->logger->log(SolrLogManager::ERROR, 'Exception while adding documents', [$e->__toString()]);
            }
        }

        return $documentsAdded;
    }
protected function addDocumentsToSolrIndex ( array $ documents ) { $ documentsAdded = false ; if ( ! count ( $ documents ) ) { return $ documentsAdded ; } try { $ this -> logger -> log ( SolrLogManager :: INFO , 'Adding ' . count ( $ documents ) . ' documents.' , $ documents ) ; // chunk adds by 20 $ documentChunks = array_chunk ( $ documents , 20 ) ; foreach ( $ documentChunks as $ documentChunk ) { $ response = $ this -> solrConnection -> getWriteService ( ) -> addDocuments ( $ documentChunk ) ; if ( $ response -> getHttpStatus ( ) != 200 ) { throw new \ RuntimeException ( 'Solr Request failed.' , 1331834983 ) ; } } $ documentsAdded = true ; } catch ( \ Exception $ e ) { $ this -> logger -> log ( SolrLogManager :: ERROR , $ e -> getMessage ( ) . ' Error code: ' . $ e -> getCode ( ) ) ; if ( $ this -> configuration -> getLoggingExceptions ( ) ) { $ this -> logger -> log ( SolrLogManager :: ERROR , 'Exception while adding documents' , [ $ e -> __toString ( ) ] ) ; } } return $ documentsAdded ; }
Adds the collected documents to the Solr index.

@param array $documents An array of Document objects.
@return bool TRUE if documents were added successfully, FALSE otherwise
Adds the collected documents to the Solr index .