5 * Install, update, and uninstall functions for the Search module.
9 * Implements hook_schema().
11 function search_schema() {
12 $schema['search_dataset'] = [
13 'description' => 'Stores items that will be searched.',
20 'description' => 'Search item ID, e.g. node ID for nodes.',
23 'type' => 'varchar_ascii',
26 'description' => 'The {languages}.langcode of the item variant.',
30 'type' => 'varchar_ascii',
33 'description' => 'Type of item, e.g. node.',
39 'description' => 'List of space-separated words from the item.',
46 'description' => 'Set to force node reindexing.',
49 'primary key' => ['sid', 'langcode', 'type'],
52 $schema['search_index'] = [
53 'description' => 'Stores the search index, associating words, items and scores.',
60 'description' => 'The {search_total}.word that is associated with the search item.',
67 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
70 'type' => 'varchar_ascii',
73 'description' => 'The {languages}.langcode of the item variant.',
77 'type' => 'varchar_ascii',
80 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
85 'description' => 'The numeric score of the word, higher being more important.',
89 'sid_type' => ['sid', 'langcode', 'type'],
93 'table' => 'search_dataset',
96 'langcode' => 'langcode',
101 'primary key' => ['word', 'sid', 'langcode', 'type'],
104 $schema['search_total'] = [
105 'description' => 'Stores search totals for words.',
108 'description' => 'Primary Key: Unique word in the search index.',
115 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
120 'primary key' => ['word'],
127 * Implements hook_requirements().
129 * For the Status Report, return information about search index status.
131 function search_requirements($phase) {
134 if ($phase == 'runtime') {
137 $search_page_repository = \Drupal::service('search.search_page_repository');
138 foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
139 $status = $entity->getPlugin()->indexStatus();
140 $remaining += $status['remaining'];
141 $total += $status['total'];
144 $done = $total - $remaining;
145 // Use floor() to calculate the percentage, so if it is not quite 100%, it
146 // will show as 99%, to indicate "almost done".
147 $percent = ($total > 0 ? floor(100 * $done / $total) : 100);
148 $requirements['search_status'] = [
149 'title' => t('Search index progress'),
150 'value' => t('@percent% (@remaining remaining)', ['@percent' => $percent, '@remaining' => $remaining]),
151 'severity' => REQUIREMENT_INFO,
155 return $requirements;