search.install

  1. 7.x drupal-7.x/modules/search/search.install
  2. 6.x drupal-6.x/modules/search/search.install

File

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