summaryrefslogtreecommitdiff
path: root/modules/search/search.install
blob: 93c8a2fa57d213a99b7bbc911768704e24149281 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
// $Id$

/**
 * 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' => t('Stores items that will be searched.'),
    'fields' => array(
      'sid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Search item ID, e.g. node ID for nodes.'),
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => FALSE,
        'description' => t('Type of item, e.g. node.'),
      ),
      'data' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('List of space-separated words from the item.'),
      ),
    ),
    'indexes' => array('sid_type' => array('sid', 'type')),
  );

  $schema['search_index'] = array(
    'description' => t('Stores the search index, associating words, items and scores.'),
    'fields' => array(
      'word' => array(
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
        'description' => t('The {search_total}.word that is associated with the search item.'),
      ),
      'sid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {search_dataset}.sid of the searchable item to which the word belongs.'),
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => FALSE,
        'description' => t('The {search_dataset}.type of the searchable item to which the word belongs.'),
      ),
      'fromsid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {search_dataset}.sid of the referring link to this item.'),
      ),
      'fromtype' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => FALSE,
        'description' => t('The {search_dataset}.type of the referring link to this item.'),
      ),
      'score' => array(
        'type' => 'float',
        'not null' => FALSE,
        'description' => t('The numeric score of the word, higher being more important.'),
      ),
    ),
    'indexes' => array(
      'from_sid_type' => array('fromsid', 'fromtype'),
      'sid_type' => array('sid', 'type'),
      'word' => array('word')
    ),
  );

  $schema['search_total'] = array(
    'description' => t('Stores search totals for words.'),
    'fields' => array(
      'word' => array(
        'description' => t('Primary Key: Unique word in the search index.'),
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
      'count' => array(
        'description' => t("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'),
  );

  return $schema;
}