function node_update_index

Implements hook_update_index().

8 calls to node_update_index()
SearchAdvancedSearchFormTest::setUp in drupal/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php
Sets up a Drupal site for running functional and integration tests.
SearchCommentCountToggleTest::setUp in drupal/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
Sets up a Drupal site for running functional and integration tests.
SearchConfigSettingsFormTest::setUp in drupal/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
Sets up a Drupal site for running functional and integration tests.
SearchEmbedFormTest::setUp in drupal/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php
Sets up a Drupal site for running functional and integration tests.
SearchMultilingualEntityTest::testIndexingThrottle in drupal/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
Tests for indexing throttle with nodes in multiple languages.

... See full list

File

drupal/core/modules/node/node.module, line 2185
The core module that allows content to be submitted to the site.

Code

function node_update_index() {
  $limit = (int) config('search.settings')
    ->get('index.cron_limit');
  $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array(
    'target' => 'slave',
  ));
  $nids = $result
    ->fetchCol();
  if (!$nids) {
    return;
  }

  // The indexing throttle should be aware of the number of language variants
  // of a node.
  $counter = 0;
  foreach (node_load_multiple($nids) as $node) {

    // Determine when the maximum number of indexable items is reached.
    $counter += count($node
      ->getTranslationLanguages());
    if ($counter > $limit) {
      break;
    }
    _node_index_node($node);
  }
}