From d6b563d051ce2300c227e7e8c0d57b9a475546d1 Mon Sep 17 00:00:00 2001 From: Nenad Ticaric Date: Sat, 28 May 2016 00:36:30 +0200 Subject: [PATCH] handle case --- src/Support/Expression.php | 3 ++- src/TNTSearch.php | 2 +- tests/TNTSearchTest.php | 6 ++++++ tests/_files/articles.sqlite | Bin 4096 -> 4096 bytes 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Support/Expression.php b/src/Support/Expression.php index d8859df..2257c4a 100644 --- a/src/Support/Expression.php +++ b/src/Support/Expression.php @@ -90,7 +90,8 @@ public function lex($string) $good = [ '|' , '~', '&', '&', '&']; $string = str_replace($bad, $good, $string); - + $string = strtolower($string); + $tokens = []; $token = ""; foreach (str_split($string) as $char) { diff --git a/src/TNTSearch.php b/src/TNTSearch.php index 7a995bf..0e0dc68 100644 --- a/src/TNTSearch.php +++ b/src/TNTSearch.php @@ -294,7 +294,7 @@ public function info($str) public function breakIntoTokens($text) { $indexer = new TNTIndexer; - return $indexer->breakIntoTokens($text); + return $indexer->breakIntoTokens(strtolower($text)); } public function highlight($text, $needle, $tag = 'em', $options = []) diff --git a/tests/TNTSearchTest.php b/tests/TNTSearchTest.php index eefc166..7dae2a2 100644 --- a/tests/TNTSearchTest.php +++ b/tests/TNTSearchTest.php @@ -72,6 +72,12 @@ public function testSearchBoolean() $res = $tnt->searchBoolean('hamlet'); $this->assertEquals([1,2], $res['ids']); + + $res = $tnt->searchBoolean('eldred -bar'); + $this->assertEquals([11], $res['ids']); + + $res = $tnt->searchBoolean('Eldred -bar'); + $this->assertEquals([11], $res['ids']); } public function testIndexUpdate() diff --git a/tests/_files/articles.sqlite b/tests/_files/articles.sqlite index d11933fca30a7a5149ae862301393428bd394080..87cf472bdeebdb15668a514e4061ea790c12bc7f 100644 GIT binary patch delta 106 zcmZorXi%6S%_uoh#+gxaW5RrHMIK&ee+C}L0}RX$nGZ5?F;8W3Vh&~MU^>Oj%lMY@ zD&v8TjSCocg?U&QB;{RmQi@Vj{4*4CD;1Iwi^RBrf~pX~@QlO~g_4X^g|z(q&2M>y FnE=4x9fAM= delta 56 zcmZorXi%6S%_u%m#+gxkW5RrHSuS2?e+Dkbw+ze=nGZ5?F;8W3Vh&~MU^>Oj%lLL< M<3+~JZ+V580FpcpM*si-