예제 #1
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);
 }
예제 #2
0
 public function testCompleteRequest()
 {
     $this->query->addDeleteById(1);
     $this->query->addRollback();
     $this->query->addDeleteQuery('*:*');
     $this->query->addDocument(new Document(array('id' => 1)));
     $this->query->addCommit();
     $this->query->addOptimize();
     $this->assertEquals('<update>' . '<delete><id>1</id></delete>' . '<rollback/>' . '<delete><query>*:*</query></delete>' . '<add><doc><field name="id">1</field></doc></add>' . '<commit/>' . '<optimize/>' . '</update>', $this->builder->getRawData($this->query));
 }
예제 #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;
 }