function NodeSearch::indexStatus

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

File

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

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,
  ];
}

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