getIndex() public method

public getIndex ( )
Esempio n. 1
0
 public function testIndexFromFileSystem()
 {
     $config = ['driver' => 'filesystem', 'storage' => __DIR__ . '/../_files/', 'location' => __DIR__ . '/../_files/articles/', 'extension' => 'txt'];
     $tnt = new TNTSearch();
     $tnt->loadConfig($config);
     $indexer = $tnt->createIndex($this->indexName);
     $indexer->disableOutput = true;
     $indexer->run();
     $tnt->selectIndex($this->indexName);
     $index = $tnt->getIndex();
     $count = $index->countWordInWordList('document');
     $this->assertTrue($count == 3, 'Word document should be 3');
     $this->assertEquals('TeamTNT\\TNTSearch\\Stemmer\\PorterStemmer', get_class($tnt->getStemmer()));
 }
Esempio n. 2
0
 public function testFuzzySearchMultipleWordsFound()
 {
     $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);
     $index = $tnt->getIndex();
     $index->insert(['id' => '14', 'title' => '199x', 'article' => 'Nineties with the x...']);
     $index->insert(['id' => '15', 'title' => '199y', 'article' => 'Nineties with the y...']);
     $tnt->fuzziness = true;
     $res = $tnt->search('199');
     $this->assertContains(14, $res['ids']);
     $this->assertContains(15, $res['ids']);
 }