You are here

public function NodeSearch::indexStatus in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::indexStatus()

Reports the status of indexing.

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

Return value

array An associative array with the key-value pairs:

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

Overrides SearchIndexingInterface::indexStatus

File

core/modules/node/src/Plugin/Search/NodeSearch.php, line 571

Class

NodeSearch
Handles searching for node entities using the Search module index.

Namespace

Drupal\node\Plugin\Search

Code

public function indexStatus() {
  $total = $this->database
    ->query('SELECT COUNT(*) FROM {node}')
    ->fetchField();
  $remaining = $this->database
    ->query("SELECT COUNT(DISTINCT n.nid) FROM {node} n LEFT JOIN {search_dataset} sd ON sd.sid = n.nid AND sd.type = :type WHERE sd.sid IS NULL OR sd.reindex <> 0", [
    ':type' => $this
      ->getPluginId(),
  ])
    ->fetchField();
  return [
    'remaining' => $remaining,
    'total' => $total,
  ];
}