diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-01-02 10:45:34 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-01-02 10:45:34 +0000 |
commit | 89028a43bbbaf73e6aa1e8e00bc12d46d1fc7119 (patch) | |
tree | 15ab7c6806ed7339a5e9f46ffa05bfd9b62a21c5 /modules | |
parent | 712929ea6a73d9917e2c284351386e6637c79ec8 (diff) | |
download | brdo-89028a43bbbaf73e6aa1e8e00bc12d46d1fc7119.tar.gz brdo-89028a43bbbaf73e6aa1e8e00bc12d46d1fc7119.tar.bz2 |
- Patch #493770 by Garrett Albright, tobiasb: search incorrectly splits some katakana words.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/search/search.module | 10 | ||||
-rw-r--r-- | modules/search/search.test | 32 |
2 files changed, 37 insertions, 5 deletions
diff --git a/modules/search/search.module b/modules/search/search.module index 632073d24..e83c78549 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -42,11 +42,11 @@ define('PREG_CLASS_SEARCH_EXCLUDE', '\x{2108}\x{2109}\x{2114}\x{2116}-\x{2118}\x{211e}-\x{2123}\x{2125}\x{2127}' . '\x{2129}\x{212e}\x{2132}\x{213a}\x{213b}\x{2140}-\x{2144}\x{214a}-\x{2b13}' . '\x{2ce5}-\x{2cff}\x{2d6f}\x{2e00}-\x{3005}\x{3007}-\x{303b}\x{303d}-\x{303f}' . -'\x{3099}-\x{309e}\x{30a0}\x{30fb}-\x{30fe}\x{3190}-\x{319f}\x{31c0}-\x{31cf}' . -'\x{3200}-\x{33ff}\x{4dc0}-\x{4dff}\x{a015}\x{a490}-\x{a716}\x{a802}\x{a806}' . -'\x{a80b}\x{a823}-\x{a82b}\x{d800}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}\x{fd3f}' . -'\x{fdfc}-\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}\x{ff5b}-' . -'\x{ff65}\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}'); +'\x{3099}-\x{309e}\x{30a0}\x{30fb}\x{30fd}\x{30fe}\x{3190}-\x{319f}\x{31c0}-' . +'\x{31cf}\x{3200}-\x{33ff}\x{4dc0}-\x{4dff}\x{a015}\x{a490}-\x{a716}\x{a802}' . +'\x{a806}\x{a80b}\x{a823}-\x{a82b}\x{d800}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}' . +'\x{fd3f}\x{fdfc}-\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}' . +'\x{ff5b}-\x{ff65}\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}'); /** * Matches all 'N' Unicode character classes (numbers) diff --git a/modules/search/search.test b/modules/search/search.test index 035b7645d..11137c441 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -5,6 +5,7 @@ // Here we test with _test_ and _test2_ as the type. define('SEARCH_TYPE', '_test_'); define('SEARCH_TYPE_2', '_test2_'); +define('SEARCH_TYPE_JPN', '_test3_'); class SearchMatchTestCase extends DrupalWebTestCase { public static function getInfo() { @@ -42,6 +43,14 @@ class SearchMatchTestCase extends DrupalWebTestCase { for ($i = 1; $i <= 5; ++$i) { search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i)); } + // No getText builder function for Japanese text; just a simple array. + foreach (array( + 13 => '以呂波耳・ほへとち。リヌルヲ。', + 14 => 'ドルーパルが大好きよ!', + 15 => 'コーヒーとケーキ', + ) as $i => $jpn) { + search_index($i, SEARCH_TYPE_JPN, $jpn); + } search_update_totals(); } @@ -162,6 +171,29 @@ class SearchMatchTestCase extends DrupalWebTestCase { $this->_testQueryMatching($query, $set, $results); $this->_testQueryScores($query, $set, $results); } + + // These queries are run against the third index type, SEARCH_TYPE_JPN. + $queries = array( + // Simple AND queries. + '呂波耳' => array(13), + '以呂波耳' => array(13), + 'ほへと ヌルヲ' => array(13), + 'とちリ' => array(), + 'ドルーパル' => array(14), + 'パルが大' => array(14), + 'コーヒー' => array(15), + 'ヒーキ' => array(), + ); + foreach ($queries as $query => $results) { + $result = db_select('search_index', 'i') + ->extend('SearchQuery') + ->searchExpression($query, SEARCH_TYPE_JPN) + ->execute(); + + $set = $result ? $result->fetchAll() : array(); + $this->_testQueryMatching($query, $set, $results); + $this->_testQueryScores($query, $set, $results); + } } /** |