-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.install
More file actions
216 lines (206 loc) · 6.34 KB
/
Copy pathsearch.install
File metadata and controls
216 lines (206 loc) · 6.34 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/**
* @file
* Install, update, and uninstall functions for the Search module.
*/
/**
* Implements 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.',
),
'langcode' => array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
'type' => array(
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'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.',
),
),
'primary key' => array('sid', 'langcode', '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.',
),
'langcode' => array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
'type' => array(
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'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', 'langcode', 'type'),
),
'foreign keys' => array(
'search_dataset' => array(
'table' => 'search_dataset',
'columns' => array(
'sid' => 'sid',
'langcode' => 'langcode',
'type' => 'type',
),
),
),
'primary key' => array('word', 'sid', 'langcode', '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;
}
/**
* Update search module to use the configuration system.
*
* @ingroup config_upgrade
*/
function search_update_8000() {
update_variables_to_config('search.settings', array(
'minimum_word_size' => 'index.minimum_word_size',
'overlap_cjk' => 'index.overlap_cjk',
'search_cron_limit' => 'index.cron_limit',
'search_tag_weights' => 'index.tag_weights',
'search_active_modules' => 'active_modules',
'search_and_or_limit' => 'and_or_limit',
'search_default_module' => 'default_module',
));
}
/**
* Adds the langcode field and indexes to {search_dataset} and {search_index}.
*/
function search_update_8001() {
// In order to upgrade the existing entries to have the correct langcode we
// need to recreate search data through running cron.
db_truncate('search_dataset');
db_truncate('search_index');
db_truncate('search_node_links');
// Add the fields and indexes.
db_drop_primary_key('search_dataset');
db_add_field('search_dataset', 'langcode', array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
));
db_add_primary_key('search_dataset', array('sid', 'langcode', 'type'));
db_drop_primary_key('search_index');
db_drop_index('search_index', 'sid_type');
db_add_field('search_index', 'langcode', array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
array(
'indexes' => array(
'sid_type' => array('sid', 'langcode', 'type'),
),
));
db_add_primary_key('search_index', array('word', 'sid', 'langcode', 'type'));
}