ElasticsearchIndexingException 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 new ElasticsearchIndexingException($errors);
        }
    }

    private function handleLanguageIndexIteratorMessage(ElasticsearchLanguageIndexIteratorMessage $message): void
    {
        /** @var LanguageEntity|null $language */
        $language = $this->languageRepository->search(new Criteria([$message->getLanguageId()]), Context::createDefaultContext())->first();

        if ($language === null) {
            return;
        }

        
/** * @internal * * @covers \Shopware\Elasticsearch\Exception\ElasticsearchIndexingException */
class ElasticsearchIndexingExceptionTest extends TestCase
{
    public function testException(): void
    {
        Feature::skipTestIfActive('ES_MULTILINGUAL_INDEX', $this);

        $exception = new ElasticsearchIndexingException([
            'index' => 'shopware',
            'type' => 'product',
            'reason' => 'illegal_argument_exception',
            'id' => '1',
            'error' => [
                'type' => 'illegal_argument_exception',
                'reason' => 'illegal argument',
            ],
        ]);

        static::assertStringContainsString('Following errors occurred while indexing', $exception->getMessage());
        

        return $this->indexer;
    }

    public function getIndexer(string $name): AbstractAdminIndexer
    {
        $indexer = $this->indexer[$name] ?? null;
        if ($indexer) {
            return $indexer;
        }

        throw new ElasticsearchIndexingException([\sprintf('Indexer for name %s not found', $name)]);
    }

    public function updateMappings(): void
    {
        foreach ($this->indexer as $indexer) {
            $mapping = $this->buildMapping($indexer);

            $this->client->indices()->putMapping([
                'index' => $this->adminEsHelper->getIndex($indexer->getName()),
                'body' => $mapping,
            ]);
        }
Home | Imprint | This part of the site doesn't use cookies.