Example #1
0
 /**
  * @return bool
  */
 public function purge()
 {
     $update = $this->client->createUpdate();
     $update->addDeleteQuery($this->deleteQuery);
     $update->addCommit();
     $result = $this->client->update($update);
     return 0 == $result->getStatus();
 }
Example #2
0
 /**
  * @param array <string> $files
  *
  * @return array
  */
 public function load(array $files)
 {
     $update = $this->client->createUpdate();
     /** @var $loader \Nelmio\Alice\Loader\Base */
     $loader = $this->getLoader('yaml');
     $loader->setProviders($this->providers);
     foreach ($files as $file) {
         $update->addDocuments($loader->load($file));
     }
     $update->addCommit();
     if (null !== $update) {
         $this->client->execute($update);
     }
 }
 public function testPostCreateRequestUnalteredPostRequest()
 {
     $query = $this->client->createUpdate();
     $query->addDeleteById(1);
     $requestOutput = $this->client->createRequest($query);
     $requestInput = clone $requestOutput;
     $event = new PostCreateRequestEvent($this->query, $requestOutput);
     $this->plugin->postCreateRequest($event);
     $this->assertEquals($requestInput, $requestOutput);
 }
 /**
  * @param Query $query
  * @param callable $transform
  * @param null $readEndpoint
  * @param null $writeEndpoint
  */
 public function updateNoBuffer(Query $query, callable $transform, $readEndpoint = null, $writeEndpoint = null, $commit = true)
 {
     $update = $this->solarium->createUpdate();
     $documents = $this->solarium->execute($query, $readEndpoint);
     foreach ($documents as $document) {
         $update->addDocument($transform($document));
     }
     if (count($documents) > 0 && $commit === true) {
         $update->addCommit();
     }
     $this->solarium->execute($update, $writeEndpoint);
 }