function SearchIndexingInterface::updateIndex

Same name in other branches
  1. 9 core/modules/search/src/Plugin/SearchIndexingInterface.php \Drupal\search\Plugin\SearchIndexingInterface::updateIndex()
  2. 8.9.x core/modules/search/src/Plugin/SearchIndexingInterface.php \Drupal\search\Plugin\SearchIndexingInterface::updateIndex()
  3. 10 core/modules/search/src/Plugin/SearchIndexingInterface.php \Drupal\search\Plugin\SearchIndexingInterface::updateIndex()

Updates the search index for this plugin.

This method is called every cron run if the plugin has been set as an active search module on the Search settings page (admin/config/search/pages). It allows your module to add items to the built-in search index by calling the index() method on the search.index service class, or to add them to your module's own indexing mechanism.

When implementing this method, your module should index content items that were modified or added since the last run. There is a time limit for cron, so it is advisable to limit how many items you index per run using config('search.settings')->get('index.cron_limit') or with your own setting. And since the cron run could time out and abort in the middle of your run, you should update any needed internal bookkeeping on when items have last been indexed as you go rather than waiting to the end of indexing.

2 methods override SearchIndexingInterface::updateIndex()
HelpSearch::updateIndex in core/modules/help/src/Plugin/Search/HelpSearch.php
NodeSearch::updateIndex in core/modules/node/src/Plugin/Search/NodeSearch.php

File

core/modules/search/src/Plugin/SearchIndexingInterface.php, line 45

Class

SearchIndexingInterface
Defines an optional interface for SearchPlugin objects using an index.

Namespace

Drupal\search\Plugin

Code

public function updateIndex();

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.