indexingError example

$arguments = [
            'index' => $index,
            'body' => $documents,
        ];

        $result = $this->client->bulk($arguments);

        if (\is_array($result) && isset($result['errors']) && $result['errors']) {
            $errors = $this->parseErrors($result);

            throw ElasticsearchIndexingException::indexingError($errors);
        }
    }
}
/** * @internal * * @covers \Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexingException */
#[Package('core')] class ElasticsearchIndexingExceptionTest extends TestCase
{
    public function testIndexingError(): void
    {
        $res = ElasticsearchIndexingException::indexingError([[
            'index' => 'index',
            'id' => 'id',
            'type' => 'error',
            'reason' => 'Foo Error',
        ]]);

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $res->getStatusCode());
        static::assertEquals('ELASTICSEARCH_INDEXING', $res->getErrorCode());
        static::assertStringContainsString($res->getMessage(), 'Following errors occurred while indexing: ' . \PHP_EOL . 'Foo Error');
    }

    
Home | Imprint | This part of the site doesn't use cookies.