You are here

function social_search_resave_search_indexes in Open Social 8.9

Same name and namespace in other branches
  1. 8.8 modules/social_features/social_search/social_search.module \social_search_resave_search_indexes()
  2. 10.3.x modules/social_features/social_search/social_search.module \social_search_resave_search_indexes()
  3. 10.0.x modules/social_features/social_search/social_search.module \social_search_resave_search_indexes()
  4. 10.1.x modules/social_features/social_search/social_search.module \social_search_resave_search_indexes()
  5. 10.2.x modules/social_features/social_search/social_search.module \social_search_resave_search_indexes()

Re-saves search indices.

This triggers the save for all search indexes which triggers updates of fields and processors.

Parameters

array $index_ids: An array of index IDs to re-save or NULL to re-save all indices.

Throws

\Drupal\Core\Entity\EntityStorageException

2 calls to social_search_resave_search_indexes()
social_tagging_install in modules/social_features/social_tagging/social_tagging.install
Install the module.
social_tagging_update_8002 in modules/social_features/social_tagging/social_tagging.install
Toggle group index.

File

modules/social_features/social_search/social_search.module, line 296
The Social search module.

Code

function social_search_resave_search_indexes(array $index_ids = NULL) {

  // We load all indexes, we assume there will never be hundreds of search
  // indexes which would create its own problems for a site.
  $indexes = Index::loadMultiple($index_ids);

  /** @var \Drupal\search_api\IndexInterface $index */
  foreach ($indexes as $index) {

    // No need to disable and enable the index here, this worked around a
    // validation of the Search Settings form that prevented the save from being
    // triggered. However, this validation is not present in the entity save
    // logic. So a simple call to `save()` will trigger the reprocessing of
    // fields and processors.
    $index
      ->save();
  }
}