function hook_search_status

Report the status of indexing.

The core search module only invokes this hook on active modules. Implementing modules do not need to check whether they are active when calculating their return values.

Return value

An associative array with the key-value pairs:

  • remaining: The number of items left to index.
  • total: The total number of items to index.

Related topics

1 function implements hook_search_status()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_search_status in drupal/core/modules/node/node.module
Implements hook_search_status().
2 invocations of hook_search_status()
SearchMultilingualEntityTest::testIndexingThrottle in drupal/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
Tests for indexing throttle with nodes in multiple languages.
SearchSettingsForm::buildForm in drupal/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php
Implements \Drupal\Core\Form\FormInterface::buildForm().

File

drupal/core/modules/search/search.api.php, line 90
Hooks provided by the Search module.

Code

function hook_search_status() {
  $total = db_query('SELECT COUNT(DISTINCT nid) FROM {node_field_data} WHERE status = 1')
    ->fetchField();
  $remaining = db_query("SELECT COUNT(DISTINCT nid) FROM {node_field_data} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")
    ->fetchField();
  return array(
    'remaining' => $remaining,
    'total' => $total,
  );
}