diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-04-02 20:13:37 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-04-02 20:13:37 +0000 |
commit | a4aac756688f5e27e671a8a3fd7b38c008d12a6f (patch) | |
tree | e5e3f56e7b0f68f658b893c737c8a9a44485a4e0 /modules | |
parent | 2fefff5914dc583ce7f81ed13a9a918069a34634 (diff) | |
download | brdo-a4aac756688f5e27e671a8a3fd7b38c008d12a6f.tar.gz brdo-a4aac756688f5e27e671a8a3fd7b38c008d12a6f.tar.bz2 |
- Patch #218403 by Gabor, catch, Arancaytar, keith, doug, et al: duplicate entry errors in search idexer due to collation issues.
Diffstat (limited to 'modules')
-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]); |