Skip to content

Commit 0e3d20b

Browse files
author
Nik Everett
committed
Add retry_on_conflict support to bulk api
Closes ruflin#623
1 parent 78ddeb9 commit 0e3d20b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

changes.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CHANGES
22

3+
2014-06-02
4+
- add retry_on_conflict support to bulk #623
5+
36
2014-06-01
47
- toString updated to consider doc_as_upsert if sent an array source #622
58

lib/Elastica/Bulk/Action/IndexDocument.php

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ protected function _getMetadataByDocument(Document $document)
4242
'parent',
4343
'ttl',
4444
'timestamp',
45+
'retry_on_conflict',
4546
);
4647
$metadata = $document->getOptions($params, true);
4748

test/lib/Elastica/Test/BulkTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,25 @@ public function testGetPath()
616616
$this->assertEquals($indexName . '/' . $typeName . '/_bulk', $bulk->getPath());
617617
}
618618

619+
public function testRetry()
620+
{
621+
$index = $this->_createIndex();
622+
$type = $index->getType('bulk_test');
623+
$client = $index->getClient();
624+
625+
$doc1 = $type->createDocument(1, array('name' => 'Mister Fantastic'));
626+
$doc1->setOpType(Action::OP_TYPE_UPDATE);
627+
$doc1->setRetryOnConflict(5);
628+
629+
$bulk = new Bulk($client);
630+
$bulk->addDocument($doc1);
631+
632+
$actions = $bulk->getActions();
633+
634+
$metadata = $actions[0]->getMetadata();
635+
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
636+
}
637+
619638
public function udpDataProvider()
620639
{
621640
return array(

0 commit comments

Comments
 (0)