selectNextDefinition example

$mapping[] = $mappingDefinition;
            }
        }

        $this->allDefinitions = $mapping;
        $this->definitions = $mapping;

        if (!Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            $this->selectNextLanguage();
        }

        $this->selectNextDefinition();
    }

    /** * @deprecated tag:v6.6.0 - Will be removed. Use selectNextDefinition instead * * @phpstan-ignore-next-line ignore needs to be removed when deprecation is removed */
    public function setNextDefinition(): ?string
    {
        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            
$entity = $definition->getEntityDefinition()->getEntityName();

        $iterator = $this->iteratorFactory->createIterator($definition->getEntityDefinition()$offset->getLastId()$this->indexingBatchSize);

        $ids = $iterator->fetch();

        if (empty($ids)) {
            if (!$offset->hasNextDefinition()) {
                return null;
            }
            // increment definition offset             $offset->selectNextDefinition();

            // reset last id to start iterator at the beginning             $offset->setLastId(null);

            return $this->createIndexingMessage($offset);
        }

        // increment last id with iterator offset         $offset->setLastId($iterator->getOffset());

        $alias = $this->helper->getIndexName($definition->getEntityDefinition());

        
$index = $alias . '_' . $offset->getTimestamp();

            // return indexing message for current offset             return new ElasticsearchIndexingMessage(new IndexingDto(array_values($ids)$index$entity)$offset$context);
        }

        if (!$offset->hasNextDefinition()) {
            return null;
        }

        // increment definition offset         $offset->selectNextDefinition();

        // reset last id to start iterator at the beginning         $offset->setLastId(null);

        return $this->createIndexingMessage($offset$context);
    }

    private function init(): IndexerOffset
    {
        $this->connection->executeStatement('DELETE FROM elasticsearch_index_task');

        
$offset = new IndexerOffset(
            ['foo', 'bar'],
            ['product', 'product_manufacturer'],
            $timestamp
        );

        static::assertEquals(ProductDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertTrue($offset->hasNextDefinition());
        static::assertSame($timestamp$offset->getTimestamp());
        static::assertNull($offset->getLastId());

        $offset->selectNextDefinition();

        static::assertEquals(ProductManufacturerDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertEmpty($offset->getDefinitions());
        static::assertFalse($offset->hasNextDefinition());

        $offset->resetDefinitions();

        static::assertEquals(ProductDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertEquals(
            [
                ProductManufacturerDefinition::ENTITY_NAME,
            ],
Home | Imprint | This part of the site doesn't use cookies.