--- search.module 2009-12-07 17:44:33.000000000 +0200 +++ search.new.module 2010-03-31 22:29:35.000000000 +0300 @@ -831,7 +831,7 @@ $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 like '%%%s%%' OR ", count($arguments2)), 0, -4); return array($query, $arguments, $query2, $arguments2, $matches, $simple, $warning); } @@ -858,7 +858,7 @@ } } // 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); } /** @@ -1184,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]); @@ -1219,7 +1218,7 @@ } // 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('/'. $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); @@ -1277,7 +1276,7 @@ $text = (isset($newranges[0]) ? '' : '... ') . implode(' ... ', $out) .' ...'; // Highlight keywords. Must be done at once to prevent conflicts ('strong' and ''). - $text = preg_replace('/'. $boundary .'('. implode('|', $keys) .')'. $boundary .'/iu', '\0', $text); + $text = preg_replace('/'. '('. implode('|', $keys) .')' . '/iu', '\0', $text); return $text; }