Commit 67adb26 1 parent bd50df6 commit 67adb26 Copy full SHA for 67adb26
File tree 3 files changed +23
-5
lines changed
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
abstract class AbstractProvider implements ProviderInterface
11
11
{
12
-
13
12
/**
14
13
* @var string The type the provider is for
15
14
*/
@@ -48,4 +47,15 @@ abstract public function getDocuments();
48
47
* @return DocumentInterface|array
49
48
*/
50
49
abstract public function getDocument ($ id );
50
+
51
+ /**
52
+ * Returns the number of Elasticsearch documents to persist in a single bulk request
53
+ * If null is returned, the 'bulk_batch_size' of the Connection will be used
54
+ *
55
+ * @return int|null
56
+ */
57
+ public function getPersistRequestBatchSize () : ?int
58
+ {
59
+ return null ;
60
+ }
51
61
}
Original file line number Diff line number Diff line change @@ -34,4 +34,12 @@ public function getDocuments();
34
34
* @return DocumentInterface|array
35
35
*/
36
36
public function getDocument ($ id );
37
+
38
+ /**
39
+ * Returns the number of Elasticsearch documents to persist in a single bulk request
40
+ * If null is returned, the 'bulk_batch_size' of the Connection will be used
41
+ *
42
+ * @return int|null
43
+ */
44
+ public function getPersistRequestBatchSize () : ?int ;
37
45
}
Original file line number Diff line number Diff line change @@ -687,15 +687,15 @@ protected function createNewIndexWithUniqueName()
687
687
*/
688
688
protected function copyDataToNewIndex (string $ newIndex , string $ oldIndex )
689
689
{
690
- $ batchSize = $ this ->connection ->getConnectionSettings ()['bulk_batch_size ' ];
691
-
692
690
// Make sure we don't autocommit on every item in the bulk request
693
691
$ autocommit = $ this ->getConnection ()->isAutocommit ();
694
692
$ this ->getConnection ()->setAutocommit (false );
695
693
696
- $ typeDataProvider = $ this ->getDataProvider ();
694
+ $ indexDataProvider = $ this ->getDataProvider ();
695
+ $ batchSize = $ indexDataProvider ->getPersistRequestBatchSize () ?? $ this ->connection ->getConnectionSettings ()['bulk_batch_size ' ];
696
+
697
697
$ i = 1 ;
698
- foreach ($ typeDataProvider ->getDocuments () as $ document ) {
698
+ foreach ($ indexDataProvider ->getDocuments () as $ document ) {
699
699
// Temporarily override the write alias with the new physical index name, so rebuilding only happens in the new index
700
700
$ originalWriteAlias = $ this ->writeAlias ;
701
701
$ this ->setWriteAlias ($ newIndex );
You can’t perform that action at this time.
0 commit comments