public function Apache_Solr_Service::addDocument in Apache Solr Search 5
Add a Solr Document to the index
Parameters
Apache_Solr_Document $document:
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 660
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 addDocument(Apache_Solr_Document $document, $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 . '">';
$rawPost .= $this
->_documentToXmlFragment($document);
$rawPost .= '</add>';
return $this
->add($rawPost);
}