diff options
-rw-r--r-- | _test/tests/inc/indexer_indexing.test.php | 17 | ||||
-rw-r--r-- | inc/indexer.php | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/_test/tests/inc/indexer_indexing.test.php b/_test/tests/inc/indexer_indexing.test.php index 628e82e00..3d8278d6c 100644 --- a/_test/tests/inc/indexer_indexing.test.php +++ b/_test/tests/inc/indexer_indexing.test.php @@ -42,4 +42,21 @@ class indexer_indexing_test extends DokuWikiTest { $query = array('001', '01'); $this->assertEquals(array('001' => array(), '01' => array('testpage')), $indexer->lookupKey('numkey', $query)); } + + public function test_numeric_twice() { + $indexer = idx_get_indexer(); + $indexer->addPageWords('testpage', '| 1010 | Dallas |'); + $query = array('1010'); + $this->assertEquals(array('1010' => array('testpage' => 1)), $indexer->lookup($query)); + $indexer->addPageWords('notfound', '| 1010 | Dallas |'); + $this->assertEquals(array('1010' => array('testpage' => 1, 'notfound' => 1)), $indexer->lookup($query)); + } + + public function test_numeric_twice_meta() { + $indexer = idx_get_indexer(); + $indexer->addMetaKeys('testpage', 'onezero', array('1010')); + $indexer->addMetaKeys('notfound', 'onezero', array('1010')); + $query = '1010'; + $this->assertEquals(array('notfound', 'testpage'), $indexer->lookupKey('onezero', $query)); + } }
\ No newline at end of file diff --git a/inc/indexer.php b/inc/indexer.php index 658fb966b..07f29b542 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -10,7 +10,7 @@ if(!defined('DOKU_INC')) die('meh.'); // Version tag used to force rebuild on upgrade -define('INDEXER_VERSION', 7); +define('INDEXER_VERSION', 8); // set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); @@ -215,6 +215,7 @@ class Doku_Indexer { foreach (array_keys($words) as $wlen) { $word_idx = $this->getIndex('w', $wlen); foreach ($words[$wlen] as $word => $freq) { + $word = (string)$word; $wid = array_search($word, $word_idx, true); if ($wid === false) { $wid = count($word_idx); |