public function register()
 {
     $this->app['tntsearch'] = $this->app->share(function ($app) {
         $config = ['driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE'), 'username' => env('DB_USERNAME'), 'password' => env('DB_PASSWORD'), 'storage' => storage_path()];
         if (isset($app['config']['services']['tntsearch'])) {
             $config = $app['config']['services']['tntsearch'];
         }
         $tnt = new TNTSearch();
         $tnt->loadConfig($config);
         return $tnt;
     });
 }
Example #2
0
 public function testCustomPrimaryKey()
 {
     $tnt = new TNTSearch();
     $tnt->loadConfig($this->config);
     $indexer = $tnt->createIndex($this->indexName);
     $indexer->setPrimaryKey('post_id');
     $indexer->disableOutput = true;
     $indexer->query('SELECT * FROM posts;');
     $indexer->run();
     $tnt->selectIndex($this->indexName);
     $res = $tnt->search('second');
     //the most relevant doc has the id 9
     $this->assertEquals("2", $res['ids'][0]);
 }
Example #3
0
 /**
  * @expectedException     TeamTNT\TNTSearch\Exceptions\IndexNotFoundException
  * @expectedExceptionCode 1
  */
 public function testIndexDoesNotExistException()
 {
     $tnt = new TNTSearch();
     $tnt->loadConfig($this->config);
     $tnt->selectIndex('IndexThatDoesNotExist');
 }