Exemple #1
0
 public function testConfigMode()
 {
     $options = array('softcommit' => true, 'waitsearcher' => false, 'maxsegments' => 6);
     $command = new Optimize($options);
     $this->assertEquals(true, $command->getSoftCommit());
     $this->assertEquals(false, $command->getWaitSearcher());
     $this->assertEquals(6, $command->getMaxSegments());
 }
Exemple #2
0
 /**
  * Convenience method to add an optimize command.
  *
  * If you need more control, like choosing a key for the command you need to
  * create you own command instance and use the add method.
  *
  * @param boolean $softCommit
  * @param boolean $waitSearcher
  * @param int     $maxSegments
  *
  * @return self Provides fluent interface
  */
 public function addOptimize($softCommit = null, $waitSearcher = null, $maxSegments = null)
 {
     $optimize = new OptimizeCommand();
     if (null !== $softCommit) {
         $optimize->setSoftCommit($softCommit);
     }
     if (null !== $waitSearcher) {
         $optimize->setWaitSearcher($waitSearcher);
     }
     if (null !== $maxSegments) {
         $optimize->setMaxSegments($maxSegments);
     }
     return $this->add(null, $optimize);
 }
 /**
  * Build XML for an update command
  *
  * @param  Query\Command\Optimize $command
  * @return string
  */
 public function buildOptimizeXml($command)
 {
     $xml = '<optimize';
     $xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
     $xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
     $xml .= $this->attrib('maxSegments', $command->getMaxSegments());
     $xml .= '/>';
     return $xml;
 }