public function testEngineIndexAutoRebuild() { $results = $this->engine->search('Sweden'); $this->assertEquals('Viking Age', $results[0]->title); // Drop the index. No results on search $this->engine->clear('index'); $results = $this->engine->search('Sweden'); $this->assertEquals([], $results); // Auto reload index $this->engine = new Engine(); $results = $this->engine->search('Sweden'); $this->assertEquals('Viking Age', $results[0]->title); }
public function testFindKeywords() { $engine = new Engine(Config::createBuilder()->testConfig()->build()); $dataset = json_decode(file_get_contents(Env::get('TEST_DATASET_PATH'))); foreach ($dataset->data as $article) { $engine->addDocument(new Document($article->title, $article->content)); } $results = $engine->findKeywords('In computer engineering, computer architecture is the conceptual design and fundamental operational structure of a computer system.'); $this->assertEquals('computer', $results[0]['keyword']); $this->assertEquals(count($dataset->data), $engine->size()); $engine->clear('index'); $this->assertNotEquals(0, $engine->size()); $engine->clear('store'); $this->assertEquals(0, $engine->size()); }
public function tearDown() { // Set up engine and index data $engine = new Engine(); $engine->clear(); }