public function Server::indexItems in Search API 8
Indexes the specified items.
Parameters
\Drupal\search_api\IndexInterface $index: The search index for which items should be indexed.
\Drupal\search_api\Item\ItemInterface[] $items: An array of items to be indexed, keyed by their item IDs.
Return value
string[] The IDs of all items that were successfully indexed.
Throws
\Drupal\search_api\SearchApiException Thrown if indexing was prevented by a fundamental configuration error.
Overrides BackendSpecificInterface::indexItems
File
- src/
Entity/ Server.php, line 347
Class
- Server
- Defines the search server configuration entity.
Namespace
Drupal\search_api\EntityCode
public function indexItems(IndexInterface $index, array $items) {
$server_task_manager = \Drupal::getContainer()
->get('search_api.server_task_manager');
if ($server_task_manager
->execute($this)) {
return $this
->getBackend()
->indexItems($index, $items);
}
$index_label = $index
->label();
throw new SearchApiException("Could not index items on index '{$index_label}' because pending server tasks could not be executed.");
}