diff --git a/Service/Manager.php b/Service/Manager.php index 983d1074..b3a2900e 100644 --- a/Service/Manager.php +++ b/Service/Manager.php @@ -365,7 +365,7 @@ public function commit(array $params = []) { if (!empty($this->bulkQueries)) { $bulkQueries = array_merge($this->bulkQueries, $this->bulkParams); - + $bulkQueries['index']['_index'] = $this->getIndexName(); $this->eventDispatcher->dispatch( Events::PRE_COMMIT, new CommitEvent($this->getCommitMode(), $bulkQueries) @@ -436,7 +436,6 @@ public function bulk($operation, $type, array $query) $this->bulkQueries['body'][] = [ $operation => array_filter( [ - '_index' => $this->getIndexName(), '_type' => $type, '_id' => isset($query['_id']) ? $query['_id'] : null, '_ttl' => isset($query['_ttl']) ? $query['_ttl'] : null, diff --git a/Tests/Unit/Service/ManagerTest.php b/Tests/Unit/Service/ManagerTest.php index 1ef4c929..7f65e546 100644 --- a/Tests/Unit/Service/ManagerTest.php +++ b/Tests/Unit/Service/ManagerTest.php @@ -27,9 +27,12 @@ public function getTestBulkData() return [ 'index_document' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'index' => ['_index' => 'test', '_type' => 'product'], + 'index' => ['_type' => 'product'], ], [ 'field1' => 'value1', @@ -48,9 +51,12 @@ public function getTestBulkData() ], 'index_document_with_id' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'index' => ['_index' => 'test', '_type' => 'product', '_id' => 'foo'], + 'index' => ['_type' => 'product', '_id' => 'foo'], ], [ 'field1' => 'value1', @@ -70,9 +76,12 @@ public function getTestBulkData() ], 'create_document' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'create' => ['_index' => 'test', '_type' => 'product'], + 'create' => ['_type' => 'product'], ], [ 'field1' => 'value1', @@ -91,9 +100,12 @@ public function getTestBulkData() ], 'delete_document' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'delete' => ['_index' => 'test', '_type' => 'product', '_id' => 'foo'], + 'delete' => ['_type' => 'product', '_id' => 'foo'], ], ], ], @@ -109,9 +121,12 @@ public function getTestBulkData() ], 'update_doc' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'update' => ['_index' => 'test', '_type' => 'product'], + 'update' => ['_type' => 'product'], ], [ 'doc' => ['title' => 'Sample'], @@ -132,9 +147,12 @@ public function getTestBulkData() ], 'update_script' => [ 'expected' => [ + 'index' => [ + '_index' => 'test', + ], 'body' => [ [ - 'update' => ['_index' => 'test', '_type' => 'product'], + 'update' => ['_type' => 'product'], ], [ 'script' => 'ctx._source.counter += count',