diff --git modules/search/search.module modules/search/search.module index 2aea710..71ba9ae 100644 --- modules/search/search.module +++ modules/search/search.module @@ -234,6 +234,10 @@ function search_wipe($sid = NULL, $type = NULL, $reindex = FALSE) { } else { db_query("DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s'", $sid, $type); + $result = db_query("SELECT word FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type); + while ($row = db_fetch_object($result)) { + search_dirty($row->word); + } db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type); // Don't remove links if re-indexing. if (!$reindex) { @@ -283,11 +287,16 @@ function search_update_totals() { foreach (search_dirty() as $word => $dummy) { // Get total count $total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word)); - // Apply Zipf's law to equalize the probability distribution - $total = log10(1 + 1/(max(1, $total))); - db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word); - if (!db_affected_rows()) { - @db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %f)", $word, $total); + if (!$total) { + db_query("DELETE FROM {search_total} WHERE word = '%s'", $word); + } + else { + // Apply Zipf's law to equalize the probability distribution + $total = log10(1 + 1/(max(1, $total))); + db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word); + if (!db_affected_rows()) { + db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %f)", $word, $total); + } } } // Find words that were deleted from search_index, but are still in