Remove mapping and setting registries, use the reseter to configure the indexes
This commit is contained in:
parent
e83a3344e9
commit
451a5b4fc2
7 changed files with 40 additions and 160 deletions
20
Reseter.php
20
Reseter.php
|
|
@ -9,11 +9,16 @@ use Elastica_Exception_Response;
|
|||
**/
|
||||
class Reseter
|
||||
{
|
||||
protected $indexManager;
|
||||
/**
|
||||
* Index settings and mappings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $indexConfigs;
|
||||
|
||||
public function __construct(IndexManager $indexManager)
|
||||
public function __construct(array $indexConfigs)
|
||||
{
|
||||
$this->indexManager = $indexManager;
|
||||
$this->indexConfigs = $indexConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,13 +28,8 @@ class Reseter
|
|||
**/
|
||||
public function reset()
|
||||
{
|
||||
foreach ($this->indexManager->getAllIndexes() as $index) {
|
||||
try {
|
||||
$index->delete();
|
||||
} catch (Elastica_Exception_Response $e) {
|
||||
// The index does not exist
|
||||
}
|
||||
$index->create();
|
||||
foreach ($this->indexConfigs as $indexConfig) {
|
||||
$indexConfig['index']->create($indexConfig['config'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue