Commit 2b3e7315 authored by Bas de Nooijer's avatar Bas de Nooijer

Replaced deprecated waitFlush param with softCommit

parent 4a17793d
......@@ -218,18 +218,18 @@ class BufferedAdd extends Plugin
* Any remaining documents in the buffer will also be flushed
*
* @param boolean $overwrite
* @param boolean $waitFlush
* @param boolean $softCommit
* @param boolean $waitSearcher
* @param boolean $expungeDeletes
* @return UpdateResult
*/
public function commit($overwrite = null, $waitFlush = null, $waitSearcher = null, $expungeDeletes = null)
public function commit($overwrite = null, $softCommit = null, $waitSearcher = null, $expungeDeletes = null)
{
$event = new PreCommitEvent($this->buffer, $overwrite, $waitFlush, $waitSearcher, $expungeDeletes);
$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->getWaitFlush(), $event->getWaitSearcher(), $event->getExpungeDeletes());
$this->updateQuery->addCommit($event->getSoftCommit(), $event->getWaitSearcher(), $event->getExpungeDeletes());
$result = $this->client->update($this->updateQuery);
$this->clear();
......
......@@ -58,7 +58,7 @@ class PreCommit extends Event
/**
* @var boolean
*/
protected $waitFlush;
protected $softCommit;
/**
* @var boolean
......@@ -75,11 +75,11 @@ class PreCommit extends Event
*
* @param array $buffer
*/
public function __construct($buffer, $overwrite, $waitFlush, $waitSearcher, $expungeDeletes)
public function __construct($buffer, $overwrite, $softCommit, $waitSearcher, $expungeDeletes)
{
$this->buffer = $buffer;
$this->overwrite = $overwrite;
$this->waitFlush = $waitFlush;
$this->softCommit = $softCommit;
$this->waitSearcher = $waitSearcher;
$this->expungeDeletes = $expungeDeletes;
}
......@@ -144,19 +144,19 @@ class PreCommit extends Event
/**
* Optionally override the value
*
* @param boolean $waitFlush
* @param boolean $softCommit
*/
public function setWaitFlush($waitFlush)
public function setSoftCommit($softCommit)
{
$this->waitFlush = $waitFlush;
$this->softCommit = $softCommit;
}
/**
* @return boolean
*/
public function getWaitFlush()
public function getSoftCommit()
{
return $this->waitFlush;
return $this->softCommit;
}
/**
......
......@@ -58,24 +58,24 @@ class Commit extends Command
}
/**
* Get waitFlush option
* Get softCommit option
*
* @return boolean
*/
public function getWaitFlush()
public function getSoftCommit()
{
return $this->getOption('waitflush');
return $this->getOption('softcommit');
}
/**
* Set waitFlush option
* Set softCommit option
*
* @param boolean $waitFlush
* @param boolean $softCommit
* @return self Provides fluent interface
*/
public function setWaitFlush($waitFlush)
public function setSoftCommit($softCommit)
{
return $this->setOption('waitflush', $waitFlush);
return $this->setOption('softcommit', $softCommit);
}
/**
......
......@@ -57,24 +57,24 @@ class Optimize extends Command
}
/**
* Get waitFlush option
* Get softCommit option
*
* @return boolean
*/
public function getWaitFlush()
public function getSoftCommit()
{
return $this->getOption('waitflush');
return $this->getOption('softcommit');
}
/**
* Set waitFlush option
* Set softCommit option
*
* @param boolean $waitFlush
* @param boolean $softCommit
* @return self Provides fluent interface
*/
public function setWaitFlush($waitFlush)
public function setSoftCommit($softCommit)
{
return $this->setOption('waitflush', $waitFlush);
return $this->setOption('softcommit', $softCommit);
}
/**
......
......@@ -383,18 +383,18 @@ class Query extends BaseQuery
* 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 $waitFlush
* @param boolean $softCommit
* @param boolean $waitSearcher
* @param boolean $expungeDeletes
* @return self Provides fluent interface
*/
public function addCommit($waitFlush = null, $waitSearcher = null,
public function addCommit($softCommit = null, $waitSearcher = null,
$expungeDeletes = null)
{
$commit = new Command\Commit();
if (null !== $waitFlush) {
$commit->setWaitFlush($waitFlush);
if (null !== $softCommit) {
$commit->setSoftCommit($softCommit);
}
if (null !== $waitSearcher) {
......@@ -414,18 +414,18 @@ class Query extends BaseQuery
* 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 $waitFlush
* @param boolean $softCommit
* @param boolean $waitSearcher
* @param int $maxSegments
* @return self Provides fluent interface
*/
public function addOptimize($waitFlush = null, $waitSearcher = null,
public function addOptimize($softCommit = null, $waitSearcher = null,
$maxSegments = null)
{
$optimize = new Command\Optimize();
if (null !== $waitFlush) {
$optimize->setWaitFlush($waitFlush);
if (null !== $softCommit) {
$optimize->setSoftCommit($softCommit);
}
if (null !== $waitSearcher) {
......
......@@ -171,12 +171,10 @@ class RequestBuilder extends BaseRequestBuilder
{
$xml = '<delete>';
foreach ($command->getIds() as $id) {
$xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8')
. '</id>';
$xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') . '</id>';
}
foreach ($command->getQueries() as $query) {
$xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8')
. '</query>';
$xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8') . '</query>';
}
$xml .= '</delete>';
......@@ -192,7 +190,7 @@ class RequestBuilder extends BaseRequestBuilder
public function buildOptimizeXml($command)
{
$xml = '<optimize';
$xml .= $this->boolAttrib('waitFlush', $command->getWaitFlush());
$xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
$xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
$xml .= $this->attrib('maxSegments', $command->getMaxSegments());
$xml .= '/>';
......@@ -209,12 +207,9 @@ class RequestBuilder extends BaseRequestBuilder
public function buildCommitXml($command)
{
$xml = '<commit';
$xml .= $this->boolAttrib('waitFlush', $command->getWaitFlush());
$xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
$xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
$xml .= $this->boolAttrib(
'expungeDeletes',
$command->getExpungeDeletes()
);
$xml .= $this->boolAttrib('expungeDeletes',$command->getExpungeDeletes());
$xml .= '/>';
return $xml;
......
......@@ -39,15 +39,15 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase
{
$buffer = array(1,2,3);
$overwrite = true;
$waitFlush = false;
$softCommit = false;
$waitSearcher = true;
$expungeDeletes = false;
$event = new PreCommit($buffer, $overwrite, $waitFlush, $waitSearcher, $expungeDeletes);
$event = new PreCommit($buffer, $overwrite, $softCommit, $waitSearcher, $expungeDeletes);
$this->assertEquals($buffer, $event->getBuffer());
$this->assertEquals($overwrite, $event->getOverwrite());
$this->assertEquals($waitFlush, $event->getWaitFlush());
$this->assertEquals($softCommit, $event->getSoftCommit());
$this->assertEquals($waitSearcher, $event->getWaitSearcher());
$this->assertEquals($expungeDeletes, $event->getExpungeDeletes());
......@@ -95,11 +95,11 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase
*
* @param PreCommit $event
*/
public function testSetAndGetWaitFlush($event)
public function testSetAndGetSoftCommit($event)
{
$waitFlush = true;
$event->setWaitFlush($waitFlush);
$this->assertEquals($waitFlush, $event->getWaitFlush());
$softCommit = true;
$event->setSoftCommit($softCommit);
$this->assertEquals($softCommit, $event->getSoftCommit());
}
/**
......
......@@ -71,7 +71,7 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'group.cache.percent' => 50,
'group.truncate' => 'true',
'group.func' => 'log(foo)',
'group.facet' => true,
'group.facet' => 'true',
'group.format' => 'grouped',
),
$request->getParams()
......
......@@ -53,7 +53,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase
public function testConfigMode()
{
$options = array(
'waitflush' => true,
'softcommit' => true,
'waitsearcher' => false,
'expungedeletes' => true,
);
......@@ -62,7 +62,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
true,
$command->getWaitFlush()
$command->getSoftCommit()
);
$this->assertEquals(
......@@ -76,12 +76,12 @@ class CommitTest extends \PHPUnit_Framework_TestCase
);
}
public function testGetAndSetWaitFlush()
public function testGetAndSetSoftCommit()
{
$this->command->setWaitFlush(false);
$this->command->setSoftCommit(false);
$this->assertEquals(
false,
$this->command->getWaitFlush()
$this->command->getSoftCommit()
);
}
......
......@@ -45,7 +45,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase
public function testConfigMode()
{
$options = array(
'waitflush' => true,
'softcommit' => true,
'waitsearcher' => false,
'maxsegments' => 6,
);
......@@ -54,7 +54,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
true,
$command->getWaitFlush()
$command->getSoftCommit()
);
$this->assertEquals(
......@@ -76,12 +76,12 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase
);
}
public function testGetAndSetWaitFlush()
public function testGetAndSetSoftCommit()
{
$this->command->setWaitFlush(false);
$this->command->setSoftCommit(false);
$this->assertEquals(
false,
$this->command->getWaitFlush()
$this->command->getSoftCommit()
);
}
......
......@@ -74,13 +74,13 @@ class QueryTest extends \PHPUnit_Framework_TestCase
),
'key2' => array(
'type' => 'commit',
'waitflush' => true,
'softcommit' => true,
'waitsearcher' => false,
'expungedeletes' => true,
),
'key3' => array(
'type' => 'optimize',
'waitflush' => true,
'softcommit' => true,
'waitsearcher' => false,
'maxsegments' => 5,
),
......@@ -115,7 +115,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$commit = $commands['key2'];
$this->assertEquals(
true,
$commit->getWaitFlush()
$commit->getSoftCommit()
);
$this->assertEquals(
false,
......@@ -129,7 +129,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$optimize = $commands['key3'];
$this->assertEquals(
true,
$optimize->getWaitFlush()
$optimize->getSoftCommit()
);
$this->assertEquals(
false,
......@@ -368,7 +368,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
true,
$commands[0]->getWaitFlush()
$commands[0]->getSoftCommit()
);
$this->assertEquals(
......@@ -395,7 +395,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
true,
$commands[0]->getWaitFlush()
$commands[0]->getSoftCommit()
);
$this->assertEquals(
......
......@@ -253,10 +253,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testBuildOptimizeXmlWithParams()
{
$command = new OptimizeCommand(array('waitflush'=>true,'waitsearcher'=>false,'maxsegments'=>10));
$command = new OptimizeCommand(array('softcommit'=>true,'waitsearcher'=>false,'maxsegments'=>10));
$this->assertEquals(
'<optimize waitFlush="true" waitSearcher="false" maxSegments="10"/>',
'<optimize softCommit="true" waitSearcher="false" maxSegments="10"/>',
$this->builder->buildOptimizeXml($command)
);
}
......@@ -273,10 +273,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testBuildCommitXmlWithParams()
{
$command = new CommitCommand(array('waitflush'=>true,'waitsearcher'=>false,'expungedeletes'=>true));
$command = new CommitCommand(array('softcommit'=>true,'waitsearcher'=>false,'expungedeletes'=>true));
$this->assertEquals(
'<commit waitFlush="true" waitSearcher="false" expungeDeletes="true"/>',
'<commit softCommit="true" waitSearcher="false" expungeDeletes="true"/>',
$this->builder->buildCommitXml($command)
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment