summaryrefslogtreecommitdiff
path: root/modules/search/search.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/search/search.module')
-rw-r--r--modules/search/search.module27
1 files changed, 18 insertions, 9 deletions
diff --git a/modules/search/search.module b/modules/search/search.module
index 3489fd74f..d6e6350ae 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -399,6 +399,14 @@ function search_update_totals() {
/**
* Simplifies a string according to indexing rules.
+ *
+ * @param $text
+ * Text to simplify.
+ *
+ * @return
+ * Simplified text.
+ *
+ * @see hook_search_preprocess()
*/
function search_simplify($text) {
// Decode entities to UTF-8
@@ -436,6 +444,11 @@ function search_simplify($text) {
// marks, spacers, etc, to be a word boundary.
$text = preg_replace('/[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . ']+/u', ' ', $text);
+ // Truncate everything to 50 characters.
+ $words = explode(' ', $text);
+ array_walk($words, '_search_index_truncate');
+ $text = implode(' ', $words);
+
return $text;
}
@@ -486,7 +499,7 @@ function search_expand_cjk($matches) {
}
/**
- * Splits a string into tokens for indexing.
+ * Simplifies and splits a string into tokens for indexing.
*/
function search_index_split($text) {
$last = &drupal_static(__FUNCTION__);
@@ -498,7 +511,6 @@ function search_index_split($text) {
// Process words
$text = search_simplify($text);
$words = explode(' ', $text);
- array_walk($words, '_search_index_truncate');
// Save last keyword result
$last = $text;
@@ -511,6 +523,9 @@ function search_index_split($text) {
* Helper function for array_walk in search_index_split.
*/
function _search_index_truncate(&$text) {
+ if (is_numeric($text)) {
+ $text = ltrim($text, '0');
+ }
$text = truncate_utf8($text, 50);
}
@@ -644,14 +659,8 @@ function search_index($sid, $module, $text) {
foreach ($words as $word) {
// Add word to accumulator
$accum .= $word . ' ';
- $num = is_numeric($word);
// Check wordlength
- if ($num || drupal_strlen($word) >= $minimum_word_size) {
- // Normalize numbers
- if ($num) {
- $word = (int)ltrim($word, '-0');
- }
-
+ if (is_numeric($word) || drupal_strlen($word) >= $minimum_word_size) {
// Links score mainly for the target.
if ($link) {
if (!isset($results[$linknid])) {