Skip to content

Commit

Permalink
boolean fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nticaric committed May 13, 2016
1 parent 3f63d82 commit 9773bd9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/TNTSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function searchBoolean($phrase, $numOfResults = 100)
$startTimer = microtime(true);

$expression = new Expression;
$postfix = $expression->toPostfix($phrase);
$postfix = $expression->toPostfix("|" . $phrase);

foreach ($postfix as $token) {
if ($token == '&') {
$left = array_pop($stack);
Expand Down
3 changes: 3 additions & 0 deletions tests/TNTSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public function testSearchBoolean()

$res = $tnt->searchBoolean('hamlet or superman');
$this->assertEquals([1,2], $res['ids']);

$res = $tnt->searchBoolean('hamlet');
$this->assertEquals([1,2], $res['ids']);
}

public function testIndexUpdate()
Expand Down
3 changes: 2 additions & 1 deletion tests/indexer/IndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function testBreakIntoTokens()

$text = "Hi! This text contains an test@email.com. Test's email 123.";
$res = $indexer->breakIntoTokens($text);
$this->assertContains("test@email", $res);
$this->assertContains("test", $res);
$this->assertContains("email", $res);
$this->assertContains("contains", $res);
$this->assertContains("123", $res);

Expand Down

0 comments on commit 9773bd9

Please sign in to comment.