Skip to content

Commit 927aba8

Browse files
Merge pull request #31 from NicolasBarbey/main
fix indexes update
2 parents f913da7 + b28a0da commit 927aba8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Config/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<language>en_US</language>
1414
<language>fr_FR</language>
1515
</languages>
16-
<version>3.0.2</version>
16+
<version>3.0.3</version>
1717
<authors>
1818
<author>
1919
<name>Nicolas Barbey</name>

Engine/PropelEngine.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use TeamTNT\TNTSearch\Support\Collection;
77
use TntSearch\Connector\PropelConnector;
88
use TntSearch\Index\TntSearchIndexInterface;
9+
use \PDO;
910

1011
class PropelEngine extends SqliteEngine
1112
{
@@ -20,6 +21,16 @@ public function createConnector(array $config): PropelConnector
2021
return new PropelConnector;
2122
}
2223

24+
public function loadConfig(array $config)
25+
{
26+
parent::loadConfig($config);
27+
28+
if (!$this->dbh) {
29+
$connector = $this->createConnector($this->config);
30+
$this->dbh = $connector->connect($this->config);
31+
}
32+
}
33+
2334
public function saveWordlist(Collection $stems)
2435
{
2536
$terms = [];
@@ -61,7 +72,7 @@ public function saveWordlist(Collection $stems)
6172
$this->updateWordlistStmt->bindValue(':hits', $term['hits']);
6273
$this->updateWordlistStmt->bindValue(':keyword', $key);
6374
$this->updateWordlistStmt->execute();
64-
if (!$this->inMemory) {
75+
if (!$this->inMemory || !array_key_exists($key, $this->inMemoryTerms)) {
6576
$this->selectWordlistStmt->bindValue(':keyword', $key);
6677
$this->selectWordlistStmt->execute();
6778
$res = $this->selectWordlistStmt->fetch(PDO::FETCH_ASSOC);

Service/Support/TntSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getIndex(): TntIndexer
7474
$connector = $indexer->createConnector($this->config);
7575
$this->dbh = $connector->connect($this->config);
7676

77-
$indexer->setIndex($this->index);
77+
$indexer->setIndex($this->engine->index);
7878
$indexer->setStemmer($this->stemmer);
7979
$indexer->setTokenizer($this->tokenizer);
8080
$indexer->loadConfig($this->config);

0 commit comments

Comments
 (0)