Skip to content

Commit

Permalink
Update SphinxSearch class
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Feb 9, 2018
1 parent 21f1776 commit 92dc5c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2018-02-09 DariusIII
* Chg: Update SphinxSearch class
* Chg: Add patch to remove now unused triggers
* Fix: Fix migrations, add patch to remove old and insert new fulltext indexes
* Chg: Remove release_search_data table migration as that table is not used anymore. Remove db conversion script.
Expand Down
16 changes: 8 additions & 8 deletions nntmux/SphinxSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SphinxSearch
/**
* @var \Illuminate\Config\Repository|mixed
*/
protected $index;
protected $config;

/**
* Establish connection to SphinxQL.
Expand All @@ -32,9 +32,9 @@ class SphinxSearch
public function __construct()
{
$this->connection = new Connection();
$this->connection->setParams(['host' => config('sphinxsearch.host'), 'port' => config('sphinxsearch.port')]);
$this->config = config('sphinxsearch');
$this->connection->setParams(['host' => $this->config['host'], 'port' => $this->config['port']]);
$this->sphinxQL = SphinxQL::create($this->connection);
$this->index = config('sphinxsearch.index');
}

/**
Expand All @@ -46,7 +46,7 @@ public function insertRelease($parameters): void
if ($this->sphinxQL !== null && $parameters['id']) {
$this->sphinxQL
->replace()
->into($this->index)
->into($this->config['index'])
->set(['id' => $parameters['id'], 'name' => $parameters['name'], 'searchname' => $parameters['searchname'], 'fromname' => $parameters['fromname'], 'filename' => empty($parameters['filename']) ? "''" : $parameters['filename']])
->execute();
}
Expand All @@ -65,7 +65,7 @@ public function deleteRelease($identifiers): void
}
}
if ($identifiers['i'] !== false) {
$this->sphinxQL->delete()->from([$this->index])->where('id', '=', $identifiers['i']);
$this->sphinxQL->delete()->from([$this->config['index']])->where('id', '=', $identifiers['i']);
}
}

Expand Down Expand Up @@ -110,15 +110,15 @@ public function updateRelease($releaseID): void
*/
public function truncateRTIndex(): void
{
Helper::create($this->connection)->truncateRtIndex($this->index);
Helper::create($this->connection)->truncateRtIndex($this->config['index']);
}

/**
* Optimize the RT index.
*/
public function optimizeRTIndex(): void
{
Helper::create($this->connection)->flushRtIndex($this->index);
Helper::create($this->connection)->optimizeIndex($this->index);
Helper::create($this->connection)->flushRtIndex($this->config['index']);
Helper::create($this->connection)->optimizeIndex($this->config['index']);
}
}

0 comments on commit 92dc5c7

Please sign in to comment.