query('TRUNCATE TABLE '.$db->prefix.'search_matches') or error('Unable to empty search index match table', __FILE__, __LINE__, $db->error()); $db->query('TRUNCATE TABLE '.$db->prefix.'search_words') or error('Unable to empty search index words table', __FILE__, __LINE__, $db->error()); } $end_at = $start_at + $per_page; ?> <?php print htmlspecialchars($options['board_title']) ?> / Rebuilding search index... Rebuilding index... This might be a good time to put on some coffee :-)

query('SELECT DISTINCT t.id, p.id, p.message FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id WHERE t.id>='.$start_at.' AND t.id<'.$end_at.' ORDER BY t.id') or error('Unable to fetch topic/post info', __FILE__, __LINE__, $db->error()); while ($cur_post = $db->fetch_row($result)) { if ($cur_post[0] <> $cur_topic) { // Fetch subject and ID of first post in topic $result2 = $db->query('SELECT p.id, t.subject, MIN(p.posted) AS first FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE t.id='.$cur_post[0].' GROUP BY p.id, t.subject ORDER BY first LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); list($first_post, $subject) = $db->fetch_row($result2); $cur_topic = $cur_post[0]; } print 'Processing post '.$cur_post[1].' in topic '.$cur_post[0].'
'."\n"; flush(); if ($cur_post[1] == $first_post) // This is the "topic post" so we have to index the subject as well update_search_index('post', $cur_post[1], $cur_post[2], $subject); else update_search_index('post', $cur_post[1], $cur_post[2]); } // Check if there is more work to do $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE id>'.$end_at) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) print ''; else print ''; $db->close(); exit; } else { // Get the first post ID from the db $result = $db->query('SELECT id FROM '.$db->prefix.'topics ORDER BY id LIMIT 1') or error('Unable to create category', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) $first_id = $db->result($result, 0); $page_title = htmlspecialchars($options['board_title']).' / Admin / Maintenance'; $validate_form = true; $form_name = 'rebuild'; $focus_element = 'req_per_page'; require 'header.php'; admin_menu('maintenance'); ?>
Search index
Rebuild search index  
If you switched language while there were posts in the database, you should rebuild the search index (to remove stopwords). For best performance you should put the forum in maintenance mode during rebuilding. Rebuilding the search index can take a long time and will increase server load during the rebuild process!
Topics per cycle
The number of topics to process per pageview. E.g. if you were to enter 100, one hundred topics would be processed and then the page would refresh. This is to prevent the script from timing out during the rebuild process.
Topic ID to start at
The topic ID to start rebuilding at. It's default value is the first available ID in the database. Normally you wouldn't want to change this.
Empty index
Select this if you want the search index to be emptied before rebuilding (see below).
Once the process has completed you will be redirected back to this page. It is highly recommended that you have JavaScript enabled in your browser during rebuilding (for automatic redirect after a cycle has completed). If you are forced to abort the rebuild process, make a note of the last processed topic ID and enter that ID+1 in "Topic ID to start at" when/if you want to continue ("Empty index" must not be selected).