diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php index 6c24e49209..711dd99bf2 100644 --- a/phpBB/develop/search_fill.php +++ b/phpBB/develop/search_fill.php @@ -1,7 +1,7 @@ \n
\n"; //$synonym_array = file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt"); // This needs fixing! Shouldn't be hardcoded to English files! -$stopword_array = file($phpbb_root_path . "language/lang_english/search_stopwords.txt"); +//$stopword_array = file($phpbb_root_path . "language/lang_english/search_stopwords.txt"); $synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms.txt"); - +/* for ($j = 0; $j < count($stopword_array); $j++) { $filter_word = trim(strtolower($stopword_array[$j])); $search[] = "/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is"; $replace[] = ''; } - -for ($j = 0; $j < count($synonym_list); $j++) -{ - list($replace_synonym, $match_synonym) = split(" ", trim(strtolower($synonym_list[$j]))); - $search[] = "/\b" . phpbb_preg_quote(trim($match_synonym), "/") . "\b/is"; - $replace[] = " " . trim($replace_synonym) . " "; -} +*/ // // Fetch a batch of posts_text entries // -$sql = " - SELECT count(*) as total, max(post_id) as max_post_id +$sql = "SELECT count(*) as total, max(post_id) as max_post_id FROM ". POSTS_TEXT_TABLE; if(!$result = $db->sql_query($sql)) { @@ -63,8 +56,8 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize) $batchend = $postcounter + $batchsize; $batchcount++; - $sql = "SELECT * - FROM " . POSTS_TEXT_TABLE ." + $sql = "SELECT * + FROM " . POSTS_TEXT_TABLE . " WHERE post_id BETWEEN $batchstart AND $batchend"; @@ -92,105 +85,93 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize) $matches = array(); $post_id = $rowset[$post_nr]['post_id']; - $data = $rowset[$post_nr]['post_text']; // Raw data + $text = clean_words("post", $rowset[$post_nr]['post_text'], $synonym_array); // Cleaned up post + $text_title = clean_words("post", $rowset[$post_nr]['post_subject'], $synonym_array); - $text = clean_words($data, $search, $replace); // Cleaned up post - $matches = split_words($text); - $num_matches = count($matches); - if($num_matches < 1) + $matches = array(); + $matches['text'] = split_words($text); + $matches['title'] = split_words($text_title); + + while( list($match_type, $match_ary) = @each($matches) ) { - // Skip this post if no words where found - continue; - } + $title_match = ( $match_type == 'title' ) ? 1 : 0; - $word = array(); - $word_count = array(); - $sql_in = ""; - $phrase_string = $text; + $num_matches = count($match_ary); - // For all words in the posting - $sql_insert = ''; - $sql_select = ''; - for($j = 0; $j < $num_matches; $j++) - { - $this_word = strtolower(trim($matches[$j])); - if($this_word != '') + if ( $num_matches < 1 ) { - $word_count[$this_word]++; - $comma = ($sql_insert != '')? ', ': ''; - - $sql_insert .= "$comma('" .$this_word. "')"; - $sql_select .= "$comma'" .$this_word. "'"; + // Skip this post if no words where found + continue; } - } - if($sql_insert == '') - { - die("no words found"); - } - - $sql = 'INSERT IGNORE INTO '.SEARCH_WORD_TABLE." - (word_text) - VALUES $sql_insert"; - if( !$result = $db->sql_query($sql) ) - { - $error = $db->sql_error(); - die("Couldn't INSERT words :: " . $sql . " :: " . $error['message']); - } - // Get the word_id's out of the DB (to see if they are already there) - $sql = "SELECT word_id, word_text - FROM ".SEARCH_WORD_TABLE." - WHERE word_text IN ($sql_select) - GROUP BY word_text"; - $result = $db->sql_query($sql); - if( !$result ) - { - $error = $db->sql_error(); - die("Couldn't select words :: " . $sql . " :: " . $error['message']); - } - if( $word_check_count = $db->sql_numrows($result) ) - { - $selected_words = $db->sql_fetchrowset($result); - } - else - { - print "Couldn't do sql_numrows