createIndex() публичный Метод

public createIndex ( $indexName )
Пример #1
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]);
 }
Пример #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']);
 }