You are here

search.install in Drupal 6

Same filename and directory in other branches
  1. 5 modules/search/search.install
  2. 7 modules/search/search.install

File

modules/search/search.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function search_install() {

  // Create tables.
  drupal_install_schema('search');
}

/**
 * Implementation of hook_uninstall().
 */
function search_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('search');
  variable_del('minimum_word_size');
  variable_del('overlap_cjk');
  variable_del('search_cron_limit');
}

/**
 * Implementation of hook_schema().
 */
function search_schema() {
  $schema['search_dataset'] = array(
    'description' => 'Stores items that will be searched.',
    'fields' => array(
      'sid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Search item ID, e.g. node ID for nodes.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => FALSE,
        'description' => 'Type of item, e.g. node.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'List of space-separated words from the item.',
      ),
      'reindex' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Set to force node reindexing.',
      ),
    ),
    'unique keys' => array(
      'sid_type' => array(
        'sid',
        'type',
      ),
    ),
  );
  $schema['search_index'] = array(
    'description' => 'Stores the search index, associating words, items and scores.',
    'fields' => array(
      'word' => array(
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The {search_total}.word that is associated with the search item.',
      ),
      'sid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => FALSE,
        'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
      ),
      'score' => array(
        'type' => 'float',
        'not null' => FALSE,
        'description' => 'The numeric score of the word, higher being more important.',
      ),
    ),
    'indexes' => array(
      'sid_type' => array(
        'sid',
        'type',
      ),
      'word' => array(
        'word',
      ),
    ),
    'unique keys' => array(
      'word_sid_type' => array(
        'word',
        'sid',
        'type',
      ),
    ),
  );
  $schema['search_total'] = array(
    'description' => 'Stores search totals for words.',
    'fields' => array(
      'word' => array(
        'description' => 'Primary Key: Unique word in the search index.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
      'count' => array(
        'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
        'type' => 'float',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'word',
    ),
  );
  $schema['search_node_links'] = array(
    'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.',
    'fields' => array(
      'sid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.',
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {node}.nid that this item links to.',
      ),
      'caption' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
        'description' => 'The text used to link to the {node}.nid.',
      ),
    ),
    'primary key' => array(
      'sid',
      'type',
      'nid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  return $schema;
}

Functions

Namesort descending Description
search_install Implementation of hook_install().
search_schema Implementation of hook_schema().
search_uninstall Implementation of hook_uninstall().