public function Apache_Solr_Service::addDocuments in Apache Solr Search 5
Add an array of Solr Documents to the index all at once
Parameters
array $documents Should be an array of Apache_Solr_Document instances:
boolean $allowDups:
boolean $overwritePending:
boolean $overwriteCommitted:
Return value
Throws
Exception If an error occurs during the service call
File
- SolrPhpClient/
Apache/ Solr/ Service.php, line 684
Class
- Apache_Solr_Service
- Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
Code
public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true) {
$dupValue = $allowDups ? 'true' : 'false';
$pendingValue = $overwritePending ? 'true' : 'false';
$committedValue = $overwriteCommitted ? 'true' : 'false';
$rawPost = '<add allowDups="' . $dupValue . '" overwritePending="' . $pendingValue . '" overwriteCommitted="' . $committedValue . '">';
foreach ($documents as $document) {
if ($document instanceof Apache_Solr_Document) {
$rawPost .= $this
->_documentToXmlFragment($document);
}
}
$rawPost .= '</add>';
return $this
->add($rawPost);
}