File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 */
1010abstract class AbstractProvider implements ProviderInterface
1111{
12-
1312 /**
1413 * @var string The type the provider is for
1514 */
@@ -48,4 +47,15 @@ abstract public function getDocuments();
4847 * @return DocumentInterface|array
4948 */
5049 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+ }
5161}
Original file line number Diff line number Diff line change @@ -34,4 +34,12 @@ public function getDocuments();
3434 * @return DocumentInterface|array
3535 */
3636 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 ;
3745}
Original file line number Diff line number Diff line change @@ -687,15 +687,15 @@ protected function createNewIndexWithUniqueName()
687687 */
688688 protected function copyDataToNewIndex (string $ newIndex , string $ oldIndex )
689689 {
690- $ batchSize = $ this ->connection ->getConnectionSettings ()['bulk_batch_size ' ];
691-
692690 // Make sure we don't autocommit on every item in the bulk request
693691 $ autocommit = $ this ->getConnection ()->isAutocommit ();
694692 $ this ->getConnection ()->setAutocommit (false );
695693
696- $ typeDataProvider = $ this ->getDataProvider ();
694+ $ indexDataProvider = $ this ->getDataProvider ();
695+ $ batchSize = $ indexDataProvider ->getPersistRequestBatchSize () ?? $ this ->connection ->getConnectionSettings ()['bulk_batch_size ' ];
696+
697697 $ i = 1 ;
698- foreach ($ typeDataProvider ->getDocuments () as $ document ) {
698+ foreach ($ indexDataProvider ->getDocuments () as $ document ) {
699699 // Temporarily override the write alias with the new physical index name, so rebuilding only happens in the new index
700700 $ originalWriteAlias = $ this ->writeAlias ;
701701 $ this ->setWriteAlias ($ newIndex );
You can’t perform that action at this time.
0 commit comments