Chris@0: 'Stores items that will be searched.', Chris@0: 'fields' => [ Chris@0: 'sid' => [ Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'description' => 'Search item ID, e.g. node ID for nodes.', Chris@0: ], Chris@0: 'langcode' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => '12', Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'The {languages}.langcode of the item variant.', Chris@0: 'default' => '', Chris@0: ], Chris@0: 'type' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => 64, Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'Type of item, e.g. node.', Chris@0: ], Chris@0: 'data' => [ Chris@0: 'type' => 'text', Chris@0: 'not null' => TRUE, Chris@0: 'size' => 'big', Chris@0: 'description' => 'List of space-separated words from the item.', Chris@0: ], Chris@0: 'reindex' => [ Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'description' => 'Set to force node reindexing.', Chris@0: ], Chris@0: ], Chris@0: 'primary key' => ['sid', 'langcode', 'type'], Chris@0: ]; Chris@0: Chris@0: $schema['search_index'] = [ Chris@0: 'description' => 'Stores the search index, associating words, items and scores.', Chris@0: 'fields' => [ Chris@0: 'word' => [ Chris@0: 'type' => 'varchar', Chris@0: 'length' => 50, Chris@0: 'not null' => TRUE, Chris@0: 'default' => '', Chris@0: 'description' => 'The {search_total}.word that is associated with the search item.', Chris@0: ], Chris@0: 'sid' => [ Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.', Chris@0: ], Chris@0: 'langcode' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => '12', Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'The {languages}.langcode of the item variant.', Chris@0: 'default' => '', Chris@0: ], Chris@0: 'type' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => 64, Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.', Chris@0: ], Chris@0: 'score' => [ Chris@0: 'type' => 'float', Chris@0: 'not null' => FALSE, Chris@0: 'description' => 'The numeric score of the word, higher being more important.', Chris@0: ], Chris@0: ], Chris@0: 'indexes' => [ Chris@0: 'sid_type' => ['sid', 'langcode', 'type'], Chris@0: ], Chris@0: 'foreign keys' => [ Chris@0: 'search_dataset' => [ Chris@0: 'table' => 'search_dataset', Chris@0: 'columns' => [ Chris@0: 'sid' => 'sid', Chris@0: 'langcode' => 'langcode', Chris@0: 'type' => 'type', Chris@0: ], Chris@0: ], Chris@0: ], Chris@0: 'primary key' => ['word', 'sid', 'langcode', 'type'], Chris@0: ]; Chris@0: Chris@0: $schema['search_total'] = [ Chris@0: 'description' => 'Stores search totals for words.', Chris@0: 'fields' => [ Chris@0: 'word' => [ Chris@0: 'description' => 'Primary Key: Unique word in the search index.', Chris@0: 'type' => 'varchar', Chris@0: 'length' => 50, Chris@0: 'not null' => TRUE, Chris@0: 'default' => '', Chris@0: ], Chris@0: 'count' => [ Chris@0: 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.", Chris@0: 'type' => 'float', Chris@0: 'not null' => FALSE, Chris@0: ], Chris@0: ], Chris@0: 'primary key' => ['word'], Chris@0: ]; Chris@0: Chris@0: return $schema; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_requirements(). Chris@0: * Chris@0: * For the Status Report, return information about search index status. Chris@0: */ Chris@0: function search_requirements($phase) { Chris@0: $requirements = []; Chris@0: Chris@0: if ($phase == 'runtime') { Chris@0: $remaining = 0; Chris@0: $total = 0; Chris@0: $search_page_repository = \Drupal::service('search.search_page_repository'); Chris@0: foreach ($search_page_repository->getIndexableSearchPages() as $entity) { Chris@0: $status = $entity->getPlugin()->indexStatus(); Chris@0: $remaining += $status['remaining']; Chris@0: $total += $status['total']; Chris@0: } Chris@0: Chris@0: $done = $total - $remaining; Chris@0: // Use floor() to calculate the percentage, so if it is not quite 100%, it Chris@0: // will show as 99%, to indicate "almost done". Chris@0: $percent = ($total > 0 ? floor(100 * $done / $total) : 100); Chris@0: $requirements['search_status'] = [ Chris@0: 'title' => t('Search index progress'), Chris@0: 'value' => t('@percent% (@remaining remaining)', ['@percent' => $percent, '@remaining' => $remaining]), Chris@0: 'severity' => REQUIREMENT_INFO, Chris@0: ]; Chris@0: } Chris@0: Chris@0: return $requirements; Chris@0: }