From 9cd22608f618da8406397ddb0f5ae1873e39e954 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Wed, 18 Dec 2019 11:21:15 +0200 Subject: [PATCH] Fix a regression from 78b97289b6618981bad01ca35c6d8020be8ba4ad Fixes "undefined index type" during normal bulk indexing operations. Fixes #138. --- src/Documents/Bulk/BulkResponseAggregator.php | 10 ++++++---- tests/Documents/Bulk/BulkResponseAggregatorTest.php | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Documents/Bulk/BulkResponseAggregator.php b/src/Documents/Bulk/BulkResponseAggregator.php index 886e0f2..85069b0 100644 --- a/src/Documents/Bulk/BulkResponseAggregator.php +++ b/src/Documents/Bulk/BulkResponseAggregator.php @@ -1,5 +1,7 @@ errors[] = sprintf('Error "%s" reason "%s". Cause "%s" reason "%s". Index "%s", type "%s", id "%s"', - $error['type'], $error['reason'], $causedBy['type'], $causedBy['reason'], $item['_index'], - $item['_type'], $item['_id']); + $error['type'], $error['reason'], $causedBy['type'], $causedBy['reason'], $operation['_index'], + $operation['_type'], $operation['_id']); } } } diff --git a/tests/Documents/Bulk/BulkResponseAggregatorTest.php b/tests/Documents/Bulk/BulkResponseAggregatorTest.php index 7a9095a..ec444ac 100644 --- a/tests/Documents/Bulk/BulkResponseAggregatorTest.php +++ b/tests/Documents/Bulk/BulkResponseAggregatorTest.php @@ -36,9 +36,9 @@ public function testAddResponse() $response = [ 'items' => [ - // An item with an error + // An index operation with an error [ - 'type' => [ + 'index' => [ '_index' => 'foo', '_type' => 'bar', '_id' => 'baz', @@ -52,17 +52,17 @@ public function testAddResponse() ], ], ], - // An item without an error + // An delete operation without an error [ - 'type' => [ + 'delete' => [ '_index' => 'foo', '_type' => 'bar', '_id' => 'baz', ], ], - // An item with an error, but no caused_by + // An create operation with an error, but no caused_by [ - 'type' => [ + 'create' => [ '_index' => 'foo', '_type' => 'bar', '_id' => 'baz',