diff options
-rw-r--r-- | modules/search/search.module | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/search/search.module b/modules/search/search.module index 082b626d3..c5883e051 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -575,7 +575,12 @@ function search_index($sid, $type, $text) { // Insert results into search index foreach ($results[0] as $word => $score) { - db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score); + // The database will collate similar words (accented and non-accented forms, etc.), + // and the score is additive, so first add and then insert. + db_query("UPDATE {search_index} SET score = score + %d WHERE word = '%s' AND sid = '%d' AND type = '%s'", $score, $word, $sid, $type); + if (!db_affected_rows()) { + db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score); + } search_dirty($word); } unset($results[0]); |