annotate modules/search/search.install @ 19:3edae6ecd6c6 6.9

Drupal 6.9
author Franck Deroche <franck@defr.org>
date Thu, 15 Jan 2009 10:15:56 +0100
parents c1f4ac30525a
children
rev   line source
webmaster@1 1 <?php
franck@19 2 // $Id: search.install,v 1.14.2.1 2009/01/06 15:46:37 goba Exp $
webmaster@1 3
webmaster@1 4 /**
webmaster@1 5 * Implementation of hook_install().
webmaster@1 6 */
webmaster@1 7 function search_install() {
webmaster@1 8 // Create tables.
webmaster@1 9 drupal_install_schema('search');
webmaster@1 10 }
webmaster@1 11
webmaster@1 12 /**
webmaster@1 13 * Implementation of hook_uninstall().
webmaster@1 14 */
webmaster@1 15 function search_uninstall() {
webmaster@1 16 // Remove tables.
webmaster@1 17 drupal_uninstall_schema('search');
webmaster@1 18
webmaster@1 19 variable_del('minimum_word_size');
webmaster@1 20 variable_del('overlap_cjk');
webmaster@1 21 variable_del('search_cron_limit');
webmaster@1 22 }
webmaster@1 23
webmaster@1 24 /**
webmaster@1 25 * Implementation of hook_schema().
webmaster@1 26 */
webmaster@1 27 function search_schema() {
webmaster@1 28 $schema['search_dataset'] = array(
franck@19 29 'description' => 'Stores items that will be searched.',
webmaster@1 30 'fields' => array(
webmaster@1 31 'sid' => array(
webmaster@1 32 'type' => 'int',
webmaster@1 33 'unsigned' => TRUE,
webmaster@1 34 'not null' => TRUE,
webmaster@1 35 'default' => 0,
franck@19 36 'description' => 'Search item ID, e.g. node ID for nodes.',
webmaster@1 37 ),
webmaster@1 38 'type' => array(
webmaster@1 39 'type' => 'varchar',
webmaster@1 40 'length' => 16,
webmaster@1 41 'not null' => FALSE,
franck@19 42 'description' => 'Type of item, e.g. node.',
webmaster@1 43 ),
webmaster@1 44 'data' => array(
webmaster@1 45 'type' => 'text',
webmaster@1 46 'not null' => TRUE,
webmaster@1 47 'size' => 'big',
franck@19 48 'description' => 'List of space-separated words from the item.',
webmaster@1 49 ),
webmaster@1 50 'reindex' => array(
webmaster@1 51 'type' => 'int',
webmaster@1 52 'unsigned' => TRUE,
webmaster@1 53 'not null' => TRUE,
webmaster@1 54 'default' => 0,
franck@19 55 'description' => 'Set to force node reindexing.',
webmaster@1 56 ),
webmaster@1 57 ),
webmaster@1 58 'unique keys' => array('sid_type' => array('sid', 'type')),
webmaster@1 59 );
webmaster@1 60
webmaster@1 61 $schema['search_index'] = array(
franck@19 62 'description' => 'Stores the search index, associating words, items and scores.',
webmaster@1 63 'fields' => array(
webmaster@1 64 'word' => array(
webmaster@1 65 'type' => 'varchar',
webmaster@1 66 'length' => 50,
webmaster@1 67 'not null' => TRUE,
webmaster@1 68 'default' => '',
franck@19 69 'description' => 'The {search_total}.word that is associated with the search item.',
webmaster@1 70 ),
webmaster@1 71 'sid' => array(
webmaster@1 72 'type' => 'int',
webmaster@1 73 'unsigned' => TRUE,
webmaster@1 74 'not null' => TRUE,
webmaster@1 75 'default' => 0,
franck@19 76 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
webmaster@1 77 ),
webmaster@1 78 'type' => array(
webmaster@1 79 'type' => 'varchar',
webmaster@1 80 'length' => 16,
webmaster@1 81 'not null' => FALSE,
franck@19 82 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
webmaster@1 83 ),
webmaster@1 84 'score' => array(
webmaster@1 85 'type' => 'float',
webmaster@1 86 'not null' => FALSE,
franck@19 87 'description' => 'The numeric score of the word, higher being more important.',
webmaster@1 88 ),
webmaster@1 89 ),
webmaster@1 90 'indexes' => array(
webmaster@1 91 'sid_type' => array('sid', 'type'),
webmaster@1 92 'word' => array('word')
webmaster@1 93 ),
webmaster@1 94 'unique keys' => array('word_sid_type' => array('word', 'sid', 'type')),
webmaster@1 95 );
webmaster@1 96
webmaster@1 97 $schema['search_total'] = array(
franck@19 98 'description' => 'Stores search totals for words.',
webmaster@1 99 'fields' => array(
webmaster@1 100 'word' => array(
franck@19 101 'description' => 'Primary Key: Unique word in the search index.',
webmaster@1 102 'type' => 'varchar',
webmaster@1 103 'length' => 50,
webmaster@1 104 'not null' => TRUE,
webmaster@1 105 'default' => '',
webmaster@1 106 ),
webmaster@1 107 'count' => array(
franck@19 108 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
webmaster@1 109 'type' => 'float',
webmaster@1 110 'not null' => FALSE,
webmaster@1 111 ),
webmaster@1 112 ),
webmaster@1 113 'primary key' => array('word'),
webmaster@1 114 );
webmaster@1 115
webmaster@1 116 $schema['search_node_links'] = array(
franck@19 117 'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.',
webmaster@1 118 'fields' => array(
webmaster@1 119 'sid' => array(
webmaster@1 120 'type' => 'int',
webmaster@1 121 'unsigned' => TRUE,
webmaster@1 122 'not null' => TRUE,
webmaster@1 123 'default' => 0,
franck@19 124 'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.',
webmaster@1 125 ),
webmaster@1 126 'type' => array(
webmaster@1 127 'type' => 'varchar',
webmaster@1 128 'length' => 16,
webmaster@1 129 'not null' => TRUE,
webmaster@1 130 'default' => '',
franck@19 131 'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.',
webmaster@1 132 ),
webmaster@1 133 'nid' => array(
webmaster@1 134 'type' => 'int',
webmaster@1 135 'unsigned' => TRUE,
webmaster@1 136 'not null' => TRUE,
webmaster@1 137 'default' => 0,
franck@19 138 'description' => 'The {node}.nid that this item links to.',
webmaster@1 139 ),
webmaster@1 140 'caption' => array(
webmaster@1 141 'type' => 'text',
webmaster@1 142 'size' => 'big',
webmaster@1 143 'not null' => FALSE,
franck@19 144 'description' => 'The text used to link to the {node}.nid.',
webmaster@1 145 ),
webmaster@1 146 ),
webmaster@1 147 'primary key' => array('sid', 'type', 'nid'),
webmaster@1 148 'indexes' => array('nid' => array('nid')),
webmaster@1 149 );
webmaster@1 150
webmaster@1 151 return $schema;
webmaster@1 152 }
webmaster@1 153