hook_search_preprocess

Versions
4.6 – 7
hook_search_preprocess($text)

Preprocess text for the search index.

This hook is called both for text added to the search index, as well as the keywords users have submitted for searching.

This is required for example to allow Japanese or Chinese text to be searched. As these languages do not use spaces, it needs to be split into separate words before it can be indexed. There are various external libraries for this.

Parameters

$text The text to split. This is a single piece of plain-text that was extracted from between two HTML tags. Will not contain any HTML entities.

Return value

The text after processing.

Related topics

Code

modules/search/search.api.php, line 224

<?php
function hook_search_preprocess($text) {
  // Do processing on $text
  return $text;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.