Smile\ElasticsuiteThesaurus\Model\Indexer\IndexHandler::reindex PHP Method

reindex() public method

Create the synonyms index for a store id.
public reindex ( integer $storeId, string[] $synonyms, string[] $expansions ) : void
$storeId integer Store id.
$synonyms string[] Raw synonyms list.
$expansions string[] Raw expansions list.
return void
    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->indices()->create(['index' => $indexName, 'body' => $indexSettings]);
        $this->indexManager->proceedIndexInstall($indexName, $indexAlias);
        $this->cacheHelper->cleanIndexCache(ThesaurusIndex::INDEX_IDENTIER, $storeId);
    }

Usage Example

Example #1
0
 /**
  * {@inheritDoc}
  */
 public function executeFull()
 {
     $storeIds = array_keys($this->storeManager->getStores());
     foreach ($storeIds as $storeId) {
         $synonyms = $this->resourceModel->getSynonyms($storeId);
         $expansions = $this->resourceModel->getExpansions($storeId);
         $this->indexHandler->reindex($storeId, $synonyms, $expansions);
     }
 }