2006-07-13 13:14:25 +00:00
|
|
|
<?php
|
|
|
|
|
2009-05-13 19:42:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2013-02-04 19:11:11 +00:00
|
|
|
* Install, update, and uninstall functions for the Search module.
|
2009-05-13 19:42:18 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-05 14:43:26 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_schema().
|
2007-10-05 14:43:26 +00:00
|
|
|
*/
|
|
|
|
function search_schema() {
|
|
|
|
$schema['search_dataset'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores items that will be searched.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'sid' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Search item ID, e.g. node ID for nodes.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2012-08-16 14:18:38 +00:00
|
|
|
'langcode' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => '12',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => 'The {languages}.langcode of the item variant.',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 16,
|
2010-08-11 02:14:23 +00:00
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Type of item, e.g. node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'data' => array(
|
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'List of space-separated words from the item.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2007-11-13 14:04:08 +00:00
|
|
|
'reindex' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Set to force node reindexing.',
|
2007-11-13 14:04:08 +00:00
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
),
|
2012-08-16 14:18:38 +00:00
|
|
|
'primary key' => array('sid', 'langcode', 'type'),
|
2007-10-05 14:43:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$schema['search_index'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores the search index, associating words, items and scores.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'word' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 50,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {search_total}.word that is associated with the search item.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'sid' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2012-08-16 14:18:38 +00:00
|
|
|
'langcode' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => '12',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => 'The {languages}.langcode of the item variant.',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 16,
|
2010-08-11 02:14:23 +00:00
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'score' => array(
|
|
|
|
'type' => 'float',
|
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The numeric score of the word, higher being more important.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
),
|
|
|
|
'indexes' => array(
|
2012-08-16 14:18:38 +00:00
|
|
|
'sid_type' => array('sid', 'langcode', 'type'),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2009-06-01 22:07:10 +00:00
|
|
|
'foreign keys' => array(
|
2010-08-22 13:55:53 +00:00
|
|
|
'search_dataset' => array(
|
|
|
|
'table' => 'search_dataset',
|
|
|
|
'columns' => array(
|
|
|
|
'sid' => 'sid',
|
2012-08-29 09:48:59 +00:00
|
|
|
'langcode' => 'langcode',
|
2010-08-22 13:55:53 +00:00
|
|
|
'type' => 'type',
|
|
|
|
),
|
|
|
|
),
|
2009-06-01 22:07:10 +00:00
|
|
|
),
|
2012-08-16 14:18:38 +00:00
|
|
|
'primary key' => array('word', 'sid', 'langcode', 'type'),
|
2007-10-05 14:43:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$schema['search_total'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores search totals for words.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'word' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Primary Key: Unique word in the search index.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 50,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
|
|
|
),
|
|
|
|
'count' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'float',
|
|
|
|
'not null' => FALSE,
|
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
),
|
|
|
|
'primary key' => array('word'),
|
|
|
|
);
|
|
|
|
|
2007-11-13 14:04:08 +00:00
|
|
|
$schema['search_node_links'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.',
|
2007-11-13 14:04:08 +00:00
|
|
|
'fields' => array(
|
|
|
|
'sid' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.',
|
2007-11-13 14:04:08 +00:00
|
|
|
),
|
|
|
|
'type' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 16,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.',
|
2007-11-13 14:04:08 +00:00
|
|
|
),
|
|
|
|
'nid' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {node}.nid that this item links to.',
|
2007-11-13 14:04:08 +00:00
|
|
|
),
|
|
|
|
'caption' => array(
|
|
|
|
'type' => 'text',
|
|
|
|
'size' => 'big',
|
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The text used to link to the {node}.nid.',
|
2007-11-13 14:04:08 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
'primary key' => array('sid', 'type', 'nid'),
|
2008-03-15 12:31:29 +00:00
|
|
|
'indexes' => array(
|
|
|
|
'nid' => array('nid'),
|
|
|
|
),
|
2007-11-13 14:04:08 +00:00
|
|
|
);
|
|
|
|
|
2007-10-05 14:43:26 +00:00
|
|
|
return $schema;
|
|
|
|
}
|
2012-07-28 03:18:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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',
|
|
|
|
));
|
|
|
|
}
|