Search interface

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

The Drupal search interface manages a global search mechanism.

Modules may plug into this system to provide searches of different types of data. Most of the system is handled by search.module, so this must be enabled for all of the search features to work.

There are three ways to interact with the search system:

  • Specifically for searching nodes, you can implement hook_node_update_index() and hook_node_search_result(). However, note that the search system already indexes all visible output of a node; i.e., everything displayed normally by hook_view() and hook_node_view(). This is usually sufficient. You should only use this mechanism if you want additional, non-visible data to be indexed.
  • Implement hook_search_info(). This will create a search tab for your module on the /search page with a simple keyword search form. You will also need to implement hook_search_execute() to perform the search.
  • Implement hook_update_index(). This allows your module to use Drupal's HTML indexing mechanism for searching full text efficiently.

If your module needs to provide a more complicated search form, then you need to implement it yourself without hook_search_info(). In that case, you should define it as a local task (tab) under the /search page (e.g. /search/mymodule) so that users can easily find it.

File

drupal-7.x/modules/search/search.module, line 911
Enables site-wide keyword searching.

Functions

Namesort descending Location Description
callback_search_conditions drupal-7.x/modules/search/search.api.php Provide search query conditions.
hook_search_access drupal-7.x/modules/search/search.api.php Define access to a custom search routine.
hook_search_admin drupal-7.x/modules/search/search.api.php Add elements to the search settings form.
hook_search_execute drupal-7.x/modules/search/search.api.php Execute a search for a set of key words.
hook_search_info drupal-7.x/modules/search/search.api.php Define a custom search type.
hook_search_preprocess drupal-7.x/modules/search/search.api.php Preprocess text for search.
hook_search_reset drupal-7.x/modules/search/search.api.php Take action when the search index is going to be rebuilt.
hook_search_status drupal-7.x/modules/search/search.api.php Report the status of indexing.
hook_update_index drupal-7.x/modules/search/search.api.php Update the search index for this module.
search_box drupal-7.x/modules/search/search.module Form builder; Output a search form for the search block's search box.
search_box_form_submit drupal-7.x/modules/search/search.module Process a block search form submission.
search_data drupal-7.x/modules/search/search.module Performs a search by calling hook_search_execute().
search_excerpt drupal-7.x/modules/search/search.module Returns snippets from a piece of text, with certain keywords highlighted. Used for formatting search results.
search_form drupal-7.x/modules/search/search.module Builds a search form.
search_index drupal-7.x/modules/search/search.module Update the full-text search index for a particular item.
template_preprocess_search_block_form drupal-7.x/modules/search/search.module Process variables for search-block-form.tpl.php.