/** * 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); }
/** * 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; }
/** * 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); }