Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nticaric committed Jul 14, 2023
1 parent 16ef36d commit 9a02543
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/EngineContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function saveToIndex($stems, $docId);
public function selectIndex($indexName);
public function saveWordlist($stems);
public function saveDoclist($terms, $docId);
public function saveHitList();
public function saveHitList($stems, $docId, $termsList);
public function delete($documentId);
public function totalDocumentsInCollection();
public function getWordFromWordList($word);
Expand Down
2 changes: 1 addition & 1 deletion src/Engines/RedisEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function saveDoclist($terms, $docId)
}
}

public function saveHitList()
public function saveHitList($stems, $docId, $termsList)
{
return;
}
Expand Down
10 changes: 7 additions & 3 deletions src/Engines/SqliteEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public function createIndex($indexName)
{
$this->indexName = $indexName;

if (file_exists($this->config['storage'] . $indexName)) {
unlink($this->config['storage'] . $indexName);
}
$this->flushIndex($indexName);

$this->index = new PDO('sqlite:' . $this->config['storage'] . $indexName);
$this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Expand Down Expand Up @@ -666,4 +664,10 @@ public function getAllDocumentsForFuzzyKeyword($words, $noLimit)
return new Collection($stmtDoc->fetchAll(PDO::FETCH_ASSOC));
}

public function flushIndex($indexName)
{
if (file_exists($this->config['storage'] . $indexName)) {
unlink($this->config['storage'] . $indexName);
}
}
}
1 change: 0 additions & 1 deletion tests/TNTSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TNTSearchTest extends PHPUnit\Framework\TestCase
'engine' => 'TeamTNT\TNTSearch\Engines\RedisEngine',
'redis_host' => '127.0.0.1',
'redis_port' => '6379',
'engine' => 'TeamTNT\TNTSearch\Engines\RedisEngine',
'database' => __DIR__ . '/_files/articles.sqlite',
'host' => 'localhost',
'username' => 'testUser',
Expand Down

0 comments on commit 9a02543

Please sign in to comment.