3 # Rebuild the fulltext search indexes. This may take a while
4 # depending on the database size and server configuration.
6 # Rebuilding is faster if you drop the index and recreate it,
7 # but that will prevent searches from working while it runs.
9 function dropTextIndex()
11 if ( wfIndexExists( "searchindex", "si_title" ) ) {
12 echo "Dropping index...\n";
13 $sql = "ALTER TABLE searchindex DROP INDEX si_title, DROP INDEX si_text";
14 $res = wfQuery($sql, DB_WRITE, "dropTextIndex" );
18 function createTextIndex()
20 echo "Rebuild the index...\n";
21 $sql = "ALTER TABLE searchindex ADD FULLTEXT si_title (si_title), " .
22 "ADD FULLTEXT si_text (si_text)";
23 $res = wfQuery($sql, DB_WRITE, "createTextIndex" );
26 function rebuildTextIndex()
28 $sql = "SELECT COUNT(*) AS count FROM cur";
29 $res = wfQuery($sql, DB_READ, "rebuildTextIndex" );
30 $s = wfFetchObject($res);
31 echo "Rebuilding index fields for {$s->count} pages...\n";
34 $sql = "SELECT cur_id, cur_namespace, cur_title, cur_text FROM cur";
35 $res = wfQuery($sql, DB_READ, "rebuildTextIndex" );
37 while( $s = wfFetchObject($res) ) {
38 $u = new SearchUpdate( $s->cur_id, $s->cur_title, $s->cur_text );
40 if ( ( (++$n) % 500) == 0) { echo "$n\n"; }