public function __construct(\Solarium\QueryType\Update\Query\Query $update, \core_kernel_classes_Resource $resource)
 {
     $this->resource = $resource;
     $this->document = $update->createDocument();
     $this->indexUri();
     $this->indexTypes();
 }
Beispiel #2
0
 /**
  * Listener for the SearchEvents::SEARCH_ENGINE_POST_INDEX event.
  *
  * Commits any remaining documents, unsets the documents and request handler
  * since they are no longer needed.
  *
  * @param SearchCollectionEvent $event
  */
 public function postIndex(SearchEngineEvent $event)
 {
     if ($this->_documents) {
         $this->_update->addDocuments($this->_documents);
     }
     $this->_update->addCommit();
     $this->_client->update($this->_update);
     unset($this->_documents, $this->_update);
 }
Beispiel #3
0
 /**
  * Commit changes.
  *
  * Any remaining documents in the buffer will also be flushed
  *
  * @param boolean $overwrite
  * @param boolean $softCommit
  * @param boolean $waitSearcher
  * @param boolean $expungeDeletes
  *
  * @return UpdateResult
  */
 public function commit($overwrite = null, $softCommit = null, $waitSearcher = null, $expungeDeletes = null)
 {
     $event = new PreCommitEvent($this->buffer, $overwrite, $softCommit, $waitSearcher, $expungeDeletes);
     $this->client->getEventDispatcher()->dispatch(Events::PRE_COMMIT, $event);
     $this->updateQuery->addDocuments($this->buffer, $event->getOverwrite());
     $this->updateQuery->addCommit($event->getSoftCommit(), $event->getWaitSearcher(), $event->getExpungeDeletes());
     $result = $this->client->update($this->updateQuery, $this->getEndpoint());
     $this->clear();
     $event = new PostCommitEvent($result);
     $this->client->getEventDispatcher()->dispatch(Events::POST_COMMIT, $event);
     return $result;
 }
Beispiel #4
0
 /**
  * Add delete command to main update query
  * 
  * @param \Solarium\QueryType\Update\Query\Query $query
  * @param int $id
  * 
  * @return self
  */
 public function addDelete(UpdateQuery $query, $id)
 {
     $query->addDeleteById($id);
     return $this;
 }
 /**
  * Build XML for a field
  *
  * Used in the add command
  *
  * @param  string $name
  * @param  float  $boost
  * @param  mixed  $value
  * @param  string $modifier
  * @param  UpdateQuery $query
  * @return string
  */
 protected function buildFieldXml($name, $boost, $value, $modifier = null, $query = null)
 {
     if ($value instanceof \DateTime) {
         $value = $query->getHelper()->formatDate($value);
     }
     $xml = '<field name="' . $name . '"';
     $xml .= $this->attrib('boost', $boost);
     $xml .= $this->attrib('update', $modifier);
     $xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
     $xml .= '</field>';
     return $xml;
 }
 /**
  * Add multiple documents to the data store.
  *
  * @param \Solarium\QueryType\Update\Query\Query $updateQuery
  * @param array $documents
  */
 protected function addDocuments(Query $updateQuery, array $documents)
 {
     $updateQuery->addDocuments($documents);
     $this->client->update($updateQuery);
 }
 public function testInvalidCommandInRequest()
 {
     $this->query->add('invalidcommand', new InvalidCommand());
     $this->setExpectedException('Solarium\\Exception\\RuntimeException');
     $this->builder->build($this->query);
 }
 /**
  * Remove current document from SearchEngine index.
  *
  * @param Solarium\QueryType\Update\Query\Query $update
  *
  * @return boolean
  *
  * @throws \RuntimeException If no document is available.
  */
 public function remove(Query $update)
 {
     if (null !== $this->document) {
         $update->addDeleteById($this->getDocument()->id);
         return true;
     } else {
         return false;
     }
 }