totalDocumentsInCollection() public method

Esempio n. 1
0
 public function testMultipleSearch()
 {
     $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->search('Othello');
     $this->assertEmpty($res['ids']);
     $this->assertEquals(12, $tnt->totalDocumentsInCollection());
     $index = $tnt->getIndex();
     $count = $index->countWordInWordList('Othello');
     $this->assertTrue($count == 0, 'Word Othello should be 0');
     $index->insert(['id' => '13', 'title' => 'Othello', 'article' => 'For she had eyes and chose me.']);
     $count = $index->countWordInWordList('Othello');
     $this->assertEquals(1, $count, 'Word Othello should be 1');
     $this->assertEquals(13, $tnt->totalDocumentsInCollection());
     $res = $tnt->search('Othello');
     $this->assertEquals([13], $res['ids']);
 }