- Patch #218403 by Gabor, catch, Arancaytar, keith, doug, et al: duplicate entry errors in search idexer due to collation issues.

merge-requests/26/head
Dries Buytaert 2008-04-02 20:13:37 +00:00
parent 2fefff5914
commit a4aac75668
1 changed files with 6 additions and 1 deletions

View File

@ -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]);