Skip to content

Commit

Permalink
Add retry_on_conflict support to bulk api
Browse files Browse the repository at this point in the history
Closes ruflin#623
  • Loading branch information
Nik Everett committed Jun 2, 2014
1 parent 78ddeb9 commit 0e3d20b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CHANGES

2014-06-02
- add retry_on_conflict support to bulk #623

2014-06-01
- toString updated to consider doc_as_upsert if sent an array source #622

Expand Down
1 change: 1 addition & 0 deletions lib/Elastica/Bulk/Action/IndexDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function _getMetadataByDocument(Document $document)
'parent',
'ttl',
'timestamp',
'retry_on_conflict',
);
$metadata = $document->getOptions($params, true);

Expand Down
19 changes: 19 additions & 0 deletions test/lib/Elastica/Test/BulkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,25 @@ public function testGetPath()
$this->assertEquals($indexName . '/' . $typeName . '/_bulk', $bulk->getPath());
}

public function testRetry()
{
$index = $this->_createIndex();
$type = $index->getType('bulk_test');
$client = $index->getClient();

$doc1 = $type->createDocument(1, array('name' => 'Mister Fantastic'));
$doc1->setOpType(Action::OP_TYPE_UPDATE);
$doc1->setRetryOnConflict(5);

$bulk = new Bulk($client);
$bulk->addDocument($doc1);

$actions = $bulk->getActions();

$metadata = $actions[0]->getMetadata();
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
}

public function udpDataProvider()
{
return array(
Expand Down

0 comments on commit 0e3d20b

Please sign in to comment.