--- search.module	2012-09-05 11:09:13.317436898 +0100
+++ search.module-patched	2012-09-05 11:09:44.033435851 +0100
@@ -830,7 +830,8 @@
   $query = implode(' AND ', $query);
 
   // Build word-index conditions for the first pass
-  $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
+  //  $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
+  $query2 = substr(str_repeat("i.word like '%%%s%%' OR ", count($arguments2)), 0, -4);
 
   return array($query, $arguments, $query2, $arguments2, $matches, $simple, $warning);
 }
@@ -857,7 +858,8 @@
     }
   }
   // Return matching snippet and number of added words
-  return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $num_new_scores, $num_valid_words);
+  //  return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $num_new_scores, $num_valid_words);
+  return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%%%s%%'", $num_new_scores, $num_valid_words);
 }
 
 /**
@@ -1182,8 +1184,7 @@
  */
 function search_excerpt($keys, $text) {
   // We highlight around non-indexable or CJK characters.
-  $boundary = '(?:(?<=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .'])|(?=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .']))';
-
+  //  $boundary = '(?:(?<=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .'])|(?=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .']))';
   // Extract positive keywords and phrases
   preg_match_all('/ ("([^"]+)"|(?!OR)([^" ]+))/', ' '. $keys, $matches);
   $keys = array_merge($matches[2], $matches[3]);
@@ -1217,7 +1218,8 @@
       }
       // Locate a keyword (position $p), then locate a space in front (position
       // $q) and behind it (position $s)
-      if (preg_match('/'. $boundary . $key . $boundary .'/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) {
+      //  if (preg_match('/'. $boundary . $key . $boundary .'/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) {
+	  if (preg_match('/'. $key .'/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) {
         $p = $match[0][1];
         if (($q = strpos($text, ' ', max(0, $p - 60))) !== FALSE) {
           $end = substr($text, $p, 80);
@@ -1275,7 +1277,8 @@
   $text = (isset($newranges[0]) ? '' : '... ') . implode(' ... ', $out) .' ...';
 
   // Highlight keywords. Must be done at once to prevent conflicts ('strong' and '<strong>').
-  $text = preg_replace('/'. $boundary .'('. implode('|', $keys) .')'. $boundary .'/iu', '<strong>\0</strong>', $text);
+  //  $text = preg_replace('/'. $boundary .'('. implode('|', $keys) .')'. $boundary .'/iu', '<strong>\0</strong>', $text);
+  $text = preg_replace('/'. '('. implode('|', $keys) .')' . '/iu', '<strong>\0</strong>', $text);
   return $text;
 }
 
