Reindex data

@param null|int|array $entityIds
@return SaleIndexer
324116
protected function reindex($entityIds = null)
    {
        if ($entityIds !== null) {
            $this->cleanByIds($entityIds);
        } else {
			$this->cleanAll();
		}

		$connection = $this->getConnection();				      
        $select = $connection->select()->from(
            ['e' => $this->getTable('catalog_product_entity')],
            ['entity_id']
        )
        ->join(
            ['cw' => $this->getTable('store_website')],
            '',
            ['website_id']
        )
        ->join(
            ['cwd' => $this->getTable('catalog_product_index_website')],
            'cw.website_id = cwd.website_id',
            []
        )
        ->join(
            ['csg' => $this->getTable('store_group')],
            'csg.website_id = cw.website_id AND cw.default_group_id = csg.group_id',
            []
        )
        ->join(
            ['cs' => $this->getTable('store')],
            'csg.default_store_id = cs.store_id AND cs.store_id != 0',
            []
        )
        ->join(
            ['pw' => $this->getTable('catalog_product_website')],
            'pw.product_id = e.entity_id AND pw.website_id = cw.website_id',
            []
        );

        // add enable products limitation
        $statusCond = $connection->quoteInto('=?', Status::STATUS_ENABLED);       
        $this->_addAttributeToSelect(
            $select,
            'status',
            'e.entity_id',
            'cs.store_id',
            $statusCond,
            true
        );        
        
        $specialPrice = $this->_addAttributeToSelect(
            $select,
            'special_price',
            'e.entity_id',
            'cs.store_id',
            null,
            true
        );
        
        $specialFrom = $this->_addAttributeToSelect(
            $select,
            'special_from_date',
            'e.entity_id',
            'cs.store_id'
        );
        
        $specialTo = $this->_addAttributeToSelect(
            $select,
            'special_to_date',
            'e.entity_id',
            'cs.store_id'
        );        

        $currentDate = $connection->getDatePartSql('cwd.website_date');
        $specialFromDate = $connection->getDatePartSql($specialFrom);
        $specialToDate = $connection->getDatePartSql($specialTo);
               
        $select->where("{$specialToDate} >= {$currentDate}");
        $select->where("{$specialFromDate} <= {$currentDate}");
        
        if ($entityIds !== null) {
            $select->where('e.entity_id IN(?)', $entityIds);
        }
        
        $this->getConnection()->query(
			$select->insertFromSelect($this->getMainTable(), [], false)
		);
		
        return $this;
    }
1285133
public function reindex(iterable $keys): self
    {
        $this->items = $this->combineKeys($keys)->toArray();

        return $this;
    }
258503
protected function index($oids) {
    $persistenceFacade = $this->getPersistenceFacade();
    foreach($oids as $oid) {
      if (ObjectId::isValid($oid)) {
        $obj = $persistenceFacade->load($oid);
        if ($obj) {
          $this->search->addToIndex($obj);
        }
      }
    }
    $this->search->commitIndex(false);

    if ($this->getStepNumber() == $this->getNumberOfSteps()) {
      $this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
              1, [0], 'optimize');
    }
  }
1146091
private function reindexResources() {
        if (count($this->resToReindex) == 0) {
            return;
        }

        $this->begin();
        foreach (array_unique($this->resToReindex) as $i) {
            try {
                $res = $this->getResourceByUri($i);
                $res->setMetadata($res->getMetadata());
                $res->updateMetadata();
            } catch (Deleted $e) {
                
            } catch (NotFound $e) {
                
            }
        }
        $this->resToReindex = [];
        $this->commit();
    }
1250494
public function create($entityId, array $entityValues = [], $description = null, array $lookups = [Entity::LOOKUP_KEYWORDS])
    {
        $data = [
            'id' => $entityId,
            'values' => $entityValues,
            'doc' => $description,
            'lookups' => $lookups,
        ];

        $response = $this->client->post('/entities', $data);

        return $this->decodeResponse($response);
    }
345305
protected function rebuildIndex( array $prodIds )
	{
		$context = $this->getContext();
		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );

		$search = $productManager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.id', $prodIds ) );
		$search->setSlice( 0, count( $prodIds ) );

		$indexManager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
		$indexManager->rebuildIndex( $productManager->searchItems( $search ) );
	}
910660
private void rebuildIndexOneEntity(String entityTypeId, String untypedEntityId) {
    LOG.trace("Indexing [{}].[{}]... ", entityTypeId, untypedEntityId);

    // convert entity id string to typed entity id
    EntityType entityType = dataService.getEntityType(entityTypeId);
    if (null != entityType) {
      Object entityId = getTypedValue(untypedEntityId, entityType.getIdAttribute());
      String entityFullName = entityType.getId();

      Entity actualEntity = dataService.findOneById(entityFullName, entityId);

      if (null == actualEntity) {
        // Delete
        LOG.debug("Index delete [{}].[{}].", entityFullName, entityId);
        indexService.deleteById(entityType, entityId);
        return;
      }

      boolean indexEntityExists = indexService.hasIndex(entityType);
      if (!indexEntityExists) {
        LOG.debug("Create mapping of repository [{}] because it was not exist yet", entityTypeId);
        indexService.createIndex(entityType);
      }

      LOG.debug("Index [{}].[{}].", entityTypeId, entityId);
      indexService.index(actualEntity.getEntityType(), actualEntity);
    } else {
      throw new MolgenisDataException("Unknown EntityType for entityTypeId: " + entityTypeId);
    }
  }
856056
public function getMergedDataTable($resultIndices)
    {
        $dataTableFactory = new DataTableFactory(
            $this->dataNames, $this->dataType, $this->sitesId, $this->periods, $this->defaultRow);

        $index = $this->getIndexedArray($resultIndices);

        return $dataTableFactory->makeMerged($index, $resultIndices);
    }
138742
protected function reindex(array $events, int &$reindexed, SymfonyStyle $io, array $context, int $batch, bool $dryRun = false, bool $skipErrors = false): void
    {
        if ($dryRun) {
            $io->note(sprintf('DRY RUN - Would reindex event batch %d here.', $batch));
        } else {
            try {
                $this->getPbjx()->getEventSearch()->indexEvents($events, $context);
            } catch (\Throwable $e) {
                $io->error($e->getMessage());
                $io->note(sprintf('Failed to index batch %d.', $batch));
                $io->newLine(2);

                if (!$skipErrors) {
                    throw $e;
                }
            }
        }

        $reindexed += count($events);
    }
398157
public function show($entityId = 0)
    {
        $entityId = StaticFilter::filter('text', $entityId);
        $entity = null;
        try {
            $entity = $this->getEntity($entityId);
            $this->set($this->getEntityNameSingular(), $entity);
        } catch (EntityNotFoundException $caught) {
            Log::logger()->addNotice($caught->getMessage());
            $this->addWarningMessage(
                $this->getMissingEntityMessage($entityId)
            );
            $this->redirectFromMissingEntity();
        }
        return $entity;
    }
871535
def schedule_entities_reindex(entities):
    
    entities = [(e[0], e[1], e[2], dict(e[3])) for e in entities]
    return index_update.apply_async(kwargs={"index": "default", "items": entities})
1032827
public function allocateIdsToEntities(array $entities)
    {
        $this->validateBatch($entities, EntityInterface::class);

        $incompleteKeys = [];
        foreach ($entities as $entity) {
            if ($entity->key()->state() === Key::STATE_INCOMPLETE) {
                $incompleteKeys[] = $entity->key();
            }
        }

        if (!empty($incompleteKeys)) {
            $keys = $this->allocateIds($incompleteKeys);
        }

        return $entities;
    }
1355001
public function reverseMap(EntityInterface $entity): array
    {
        /** @var $entity Invoice */
        $services = [];

        foreach ($entity->getServices() as $service) {
            $services[] = [
                'id' => $service->getId(),
                'name' => $service->getName(),
                'tax_symbol' => $service->getTaxSymbol(),
                'unit' => $service->getUnit(),
                'quantity' => $this->reverseMapQuantity($service->getQuantity()),
                'unit_net_price' => $this->reverseMapPrice($service->getUnitNetPrice()),
                'net_price' => $this->reverseMapPrice($service->getNetPrice()),
                'gross_price' => $this->reverseMapPrice($service->getGrossPrice()),
                'tax_price' => $this->reverseMapPrice($service->getTaxPrice()),
                'symbol' => $service->getSymbol(),
                'discount' => $service->getDiscount(),
                'unit_net_price_before_discount' => $this->reverseMapPrice($service->getUnitNetPriceBeforeDiscount()),
            ];
        }

        return [
            'id' => $entity->getId(),
            'number' => $entity->getNumber(),
            'currency' => $entity->getCurrency(),
            'paid_price' => $this->reverseMapPrice($entity->getPaidPrice()),
            'notes' => $entity->getNotes(),
            'kind' => $entity->getKind(),
            'payment_method' => $entity->getPaymentMethod(),
            'recipient_signature' => $entity->getRecipientSignature(),
            'seller_signature' => $entity->getSellerSignature(),
            'invoice_date' => $this->reverseMapDate($entity->getInvoiceDate()),
            'sale_date' => $this->reverseMapDate($entity->getSaleDate()),
            'status' => $entity->getStatus(),
            'payment_date' => $this->reverseMapDate($entity->getPaymentDate()),
            'paid_date' => $this->reverseMapDate($entity->getPaidDate()),
            'net_price' => $this->reverseMapPrice($entity->getNetPrice()),
            'tax_price' => $this->reverseMapPrice($entity->getTaxPrice()),
            'gross_price' => $this->reverseMapPrice($entity->getGrossPrice()),
            'client_id' => $entity->getClientId(),
            'client_company_name' => $entity->getClientCompanyName(),
            'client_street' => $entity->getClientStreet(),
            'client_city' => $entity->getClientCity(),
            'client_post_code' => $entity->getClientPostCode(),
            'client_tax_code' => $entity->getClientTaxCode(),
            'client_country' => $entity->getClientCountry(),
            'bank_name' => $entity->getBankName(),
            'bank_account' => $entity->getBankAccount(),
            'swift' => $entity->getSwift(),
            'vat_exemption_reason' => $entity->getVatExemptionReason(),
            'sale_type' => $entity->getSaleType(),
            'invoice_date_kind' => $entity->getInvoiceDateKind(),
            'services' => $services,
        ];
    }
445818
public function delete($entityId)
    {
        $this->preDelete($entityId);
        $return = $this->doDelete($entityId);
        $this->postDelete($entityId);

        return $return;
    }
954816
public function reindex($storeId, $synonyms, $expansions)
    {
        $indexIdentifier = ThesaurusIndex::INDEX_IDENTIER;
        $indexName       = $this->indexSettingsHelper->createIndexNameFromIdentifier($indexIdentifier, $storeId);
        $indexAlias      = $this->indexSettingsHelper->getIndexAliasFromIdentifier($indexIdentifier, $storeId);
        $indexSettings   = ['settings' => $this->getIndexSettings($synonyms, $expansions)];
        $this->client->createIndex($indexName, $indexSettings);
        $this->indexManager->proceedIndexInstall($indexName, $indexAlias);
        $this->cacheHelper->cleanIndexCache(ThesaurusIndex::INDEX_IDENTIER, $storeId);
    }
1199205
public function getFromEntityByIds(string $entityFrom, array $entityIds, array $filterParams = [])
    {
        $uriAppend = "from/{$entityFrom}";
        $params    = ['entityIds' => implode(",", $entityIds)];
        if ($filterParams) {
            $params['params'] = json_encode([$filterParams]);
        }

        $response = $this->handler->handle('GET', false, $uriAppend, $params)->getData();
        if (!$response) {
            return [];
        }

        $functionalNames = [];
        if (isset($filterParams['functionalNames']) && $filterParams['functionalNames']) {
            $functionalNames = $filterParams['functionalNames'];
        }

        return $this->client->elastic()
                            ->search($this->prepareElasticSearchBody($response, ['functionalNameId' => $functionalNames]))
                            ->all();
    }
425570
public function findByIds(array $ids): array
    {
        $result = [];
        if (count($ids) > 0) {
            $queryBuilder = $this->entityManager->createQueryBuilder();
            $queryBuilder->select('i')
                         ->from(Item::class, 'i')
                         ->andWhere('i.id IN (:ids)')
                         ->setParameter('ids', array_values($ids));

            $result = $queryBuilder->getQuery()->getResult();
        }
        return $result;
    }