searchBoolean() public method

public searchBoolean ( $phrase, $numOfResults = 100 )
Example #1
0
 public function testSearchBoolean()
 {
     $tnt = new TNTSearch();
     $tnt->loadConfig($this->config);
     $indexer = $tnt->createIndex($this->indexName);
     $indexer->disableOutput = true;
     $indexer->query('SELECT id, title, article FROM articles;');
     $indexer->run();
     $tnt->selectIndex($this->indexName);
     $res = $tnt->searchBoolean('romeo juliet queen');
     $this->assertEquals([7], $res['ids']);
     $res = $tnt->searchBoolean('Hamlet or Macbeth');
     $this->assertEquals([3, 4, 1, 2], $res['ids']);
     $this->assertEquals(4, $res['hits']);
     $res = $tnt->searchBoolean('juliet -well');
     $this->assertEquals([5, 6, 7, 8, 10], $res['ids']);
     $res = $tnt->searchBoolean('juliet -romeo');
     $this->assertEquals([10], $res['ids']);
     $res = $tnt->searchBoolean('hamlet -king');
     $this->assertEquals([2], $res['ids']);
     $res = $tnt->searchBoolean('hamlet superman');
     $this->assertEquals([], $res['ids']);
     $res = $tnt->searchBoolean('hamlet or superman');
     $this->assertEquals([1, 2], $res['ids']);
     $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']);
 }