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 ...@@ -218,18 +218,18 @@ class BufferedAdd extends Plugin
* Any remaining documents in the buffer will also be flushed * Any remaining documents in the buffer will also be flushed
* *
* @param boolean $overwrite * @param boolean $overwrite
* @param boolean $waitFlush * @param boolean $softCommit
* @param boolean $waitSearcher * @param boolean $waitSearcher
* @param boolean $expungeDeletes * @param boolean $expungeDeletes
* @return UpdateResult * @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->client->getEventDispatcher()->dispatch(Events::PRE_COMMIT, $event);
$this->updateQuery->addDocuments($this->buffer, $event->getOverwrite()); $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); $result = $this->client->update($this->updateQuery);
$this->clear(); $this->clear();
......
...@@ -58,7 +58,7 @@ class PreCommit extends Event ...@@ -58,7 +58,7 @@ class PreCommit extends Event
/** /**
* @var boolean * @var boolean
*/ */
protected $waitFlush; protected $softCommit;
/** /**
* @var boolean * @var boolean
...@@ -75,11 +75,11 @@ class PreCommit extends Event ...@@ -75,11 +75,11 @@ class PreCommit extends Event
* *
* @param array $buffer * @param array $buffer
*/ */
public function __construct($buffer, $overwrite, $waitFlush, $waitSearcher, $expungeDeletes) public function __construct($buffer, $overwrite, $softCommit, $waitSearcher, $expungeDeletes)
{ {
$this->buffer = $buffer; $this->buffer = $buffer;
$this->overwrite = $overwrite; $this->overwrite = $overwrite;
$this->waitFlush = $waitFlush; $this->softCommit = $softCommit;
$this->waitSearcher = $waitSearcher; $this->waitSearcher = $waitSearcher;
$this->expungeDeletes = $expungeDeletes; $this->expungeDeletes = $expungeDeletes;
} }
...@@ -144,19 +144,19 @@ class PreCommit extends Event ...@@ -144,19 +144,19 @@ class PreCommit extends Event
/** /**
* Optionally override the value * 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 * @return boolean
*/ */
public function getWaitFlush() public function getSoftCommit()
{ {
return $this->waitFlush; return $this->softCommit;
} }
/** /**
......
...@@ -58,24 +58,24 @@ class Commit extends Command ...@@ -58,24 +58,24 @@ class Commit extends Command
} }
/** /**
* Get waitFlush option * Get softCommit option
* *
* @return boolean * @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 * @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 ...@@ -57,24 +57,24 @@ class Optimize extends Command
} }
/** /**
* Get waitFlush option * Get softCommit option
* *
* @return boolean * @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 * @return self Provides fluent interface
*/ */
public function setWaitFlush($waitFlush) public function setSoftCommit($softCommit)
{ {
return $this->setOption('waitflush', $waitFlush); return $this->setOption('softcommit', $softCommit);
} }
/** /**
......
...@@ -383,19 +383,19 @@ class Query extends BaseQuery ...@@ -383,19 +383,19 @@ class Query extends BaseQuery
* If you need more control, like choosing a key for the command you need to * 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. * create you own command instance and use the add method.
* *
* @param boolean $waitFlush * @param boolean $softCommit
* @param boolean $waitSearcher * @param boolean $waitSearcher
* @param boolean $expungeDeletes * @param boolean $expungeDeletes
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addCommit($waitFlush = null, $waitSearcher = null, public function addCommit($softCommit = null, $waitSearcher = null,
$expungeDeletes = null) $expungeDeletes = null)
{ {
$commit = new Command\Commit(); $commit = new Command\Commit();
if (null !== $waitFlush) { if (null !== $softCommit) {
$commit->setWaitFlush($waitFlush); $commit->setSoftCommit($softCommit);
} }
if (null !== $waitSearcher) { if (null !== $waitSearcher) {
$commit->setWaitSearcher($waitSearcher); $commit->setWaitSearcher($waitSearcher);
...@@ -414,18 +414,18 @@ class Query extends BaseQuery ...@@ -414,18 +414,18 @@ class Query extends BaseQuery
* If you need more control, like choosing a key for the command you need to * 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. * create you own command instance and use the add method.
* *
* @param boolean $waitFlush * @param boolean $softCommit
* @param boolean $waitSearcher * @param boolean $waitSearcher
* @param int $maxSegments * @param int $maxSegments
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addOptimize($waitFlush = null, $waitSearcher = null, public function addOptimize($softCommit = null, $waitSearcher = null,
$maxSegments = null) $maxSegments = null)
{ {
$optimize = new Command\Optimize(); $optimize = new Command\Optimize();
if (null !== $waitFlush) { if (null !== $softCommit) {
$optimize->setWaitFlush($waitFlush); $optimize->setSoftCommit($softCommit);
} }
if (null !== $waitSearcher) { if (null !== $waitSearcher) {
......
...@@ -171,12 +171,10 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -171,12 +171,10 @@ class RequestBuilder extends BaseRequestBuilder
{ {
$xml = '<delete>'; $xml = '<delete>';
foreach ($command->getIds() as $id) { foreach ($command->getIds() as $id) {
$xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') $xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') . '</id>';
. '</id>';
} }
foreach ($command->getQueries() as $query) { foreach ($command->getQueries() as $query) {
$xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8') $xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8') . '</query>';
. '</query>';
} }
$xml .= '</delete>'; $xml .= '</delete>';
...@@ -192,7 +190,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -192,7 +190,7 @@ class RequestBuilder extends BaseRequestBuilder
public function buildOptimizeXml($command) public function buildOptimizeXml($command)
{ {
$xml = '<optimize'; $xml = '<optimize';
$xml .= $this->boolAttrib('waitFlush', $command->getWaitFlush()); $xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
$xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher()); $xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
$xml .= $this->attrib('maxSegments', $command->getMaxSegments()); $xml .= $this->attrib('maxSegments', $command->getMaxSegments());
$xml .= '/>'; $xml .= '/>';
...@@ -209,12 +207,9 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -209,12 +207,9 @@ class RequestBuilder extends BaseRequestBuilder
public function buildCommitXml($command) public function buildCommitXml($command)
{ {
$xml = '<commit'; $xml = '<commit';
$xml .= $this->boolAttrib('waitFlush', $command->getWaitFlush()); $xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
$xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher()); $xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
$xml .= $this->boolAttrib( $xml .= $this->boolAttrib('expungeDeletes',$command->getExpungeDeletes());
'expungeDeletes',
$command->getExpungeDeletes()
);
$xml .= '/>'; $xml .= '/>';
return $xml; return $xml;
......
...@@ -39,15 +39,15 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase ...@@ -39,15 +39,15 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase
{ {
$buffer = array(1,2,3); $buffer = array(1,2,3);
$overwrite = true; $overwrite = true;
$waitFlush = false; $softCommit = false;
$waitSearcher = true; $waitSearcher = true;
$expungeDeletes = false; $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($buffer, $event->getBuffer());
$this->assertEquals($overwrite, $event->getOverwrite()); $this->assertEquals($overwrite, $event->getOverwrite());
$this->assertEquals($waitFlush, $event->getWaitFlush()); $this->assertEquals($softCommit, $event->getSoftCommit());
$this->assertEquals($waitSearcher, $event->getWaitSearcher()); $this->assertEquals($waitSearcher, $event->getWaitSearcher());
$this->assertEquals($expungeDeletes, $event->getExpungeDeletes()); $this->assertEquals($expungeDeletes, $event->getExpungeDeletes());
...@@ -95,11 +95,11 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase ...@@ -95,11 +95,11 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase
* *
* @param PreCommit $event * @param PreCommit $event
*/ */
public function testSetAndGetWaitFlush($event) public function testSetAndGetSoftCommit($event)
{ {
$waitFlush = true; $softCommit = true;
$event->setWaitFlush($waitFlush); $event->setSoftCommit($softCommit);
$this->assertEquals($waitFlush, $event->getWaitFlush()); $this->assertEquals($softCommit, $event->getSoftCommit());
} }
/** /**
......
...@@ -71,7 +71,7 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -71,7 +71,7 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'group.cache.percent' => 50, 'group.cache.percent' => 50,
'group.truncate' => 'true', 'group.truncate' => 'true',
'group.func' => 'log(foo)', 'group.func' => 'log(foo)',
'group.facet' => true, 'group.facet' => 'true',
'group.format' => 'grouped', 'group.format' => 'grouped',
), ),
$request->getParams() $request->getParams()
......
...@@ -53,7 +53,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase ...@@ -53,7 +53,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase
public function testConfigMode() public function testConfigMode()
{ {
$options = array( $options = array(
'waitflush' => true, 'softcommit' => true,
'waitsearcher' => false, 'waitsearcher' => false,
'expungedeletes' => true, 'expungedeletes' => true,
); );
...@@ -62,7 +62,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase ...@@ -62,7 +62,7 @@ class CommitTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
true, true,
$command->getWaitFlush() $command->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
...@@ -76,12 +76,12 @@ class CommitTest extends \PHPUnit_Framework_TestCase ...@@ -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( $this->assertEquals(
false, false,
$this->command->getWaitFlush() $this->command->getSoftCommit()
); );
} }
......
...@@ -45,7 +45,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase ...@@ -45,7 +45,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase
public function testConfigMode() public function testConfigMode()
{ {
$options = array( $options = array(
'waitflush' => true, 'softcommit' => true,
'waitsearcher' => false, 'waitsearcher' => false,
'maxsegments' => 6, 'maxsegments' => 6,
); );
...@@ -54,7 +54,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase ...@@ -54,7 +54,7 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
true, true,
$command->getWaitFlush() $command->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
...@@ -76,12 +76,12 @@ class OptimizeTest extends \PHPUnit_Framework_TestCase ...@@ -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( $this->assertEquals(
false, false,
$this->command->getWaitFlush() $this->command->getSoftCommit()
); );
} }
......
...@@ -74,13 +74,13 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -74,13 +74,13 @@ class QueryTest extends \PHPUnit_Framework_TestCase
), ),
'key2' => array( 'key2' => array(
'type' => 'commit', 'type' => 'commit',
'waitflush' => true, 'softcommit' => true,
'waitsearcher' => false, 'waitsearcher' => false,
'expungedeletes' => true, 'expungedeletes' => true,
), ),
'key3' => array( 'key3' => array(
'type' => 'optimize', 'type' => 'optimize',
'waitflush' => true, 'softcommit' => true,
'waitsearcher' => false, 'waitsearcher' => false,
'maxsegments' => 5, 'maxsegments' => 5,
), ),
...@@ -115,7 +115,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -115,7 +115,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$commit = $commands['key2']; $commit = $commands['key2'];
$this->assertEquals( $this->assertEquals(
true, true,
$commit->getWaitFlush() $commit->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
false, false,
...@@ -129,7 +129,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -129,7 +129,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$optimize = $commands['key3']; $optimize = $commands['key3'];
$this->assertEquals( $this->assertEquals(
true, true,
$optimize->getWaitFlush() $optimize->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
false, false,
...@@ -368,7 +368,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -368,7 +368,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
true, true,
$commands[0]->getWaitFlush() $commands[0]->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
...@@ -395,7 +395,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -395,7 +395,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
true, true,
$commands[0]->getWaitFlush() $commands[0]->getSoftCommit()
); );
$this->assertEquals( $this->assertEquals(
......
...@@ -253,10 +253,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -253,10 +253,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testBuildOptimizeXmlWithParams() 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( $this->assertEquals(
'<optimize waitFlush="true" waitSearcher="false" maxSegments="10"/>', '<optimize softCommit="true" waitSearcher="false" maxSegments="10"/>',
$this->builder->buildOptimizeXml($command) $this->builder->buildOptimizeXml($command)
); );
} }
...@@ -273,10 +273,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -273,10 +273,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testBuildCommitXmlWithParams() 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( $this->assertEquals(
'<commit waitFlush="true" waitSearcher="false" expungeDeletes="true"/>', '<commit softCommit="true" waitSearcher="false" expungeDeletes="true"/>',
$this->builder->buildCommitXml($command) $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