2011-04-13 00:14:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FOQ\ElasticaBundle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes and recreates indexes
|
|
|
|
**/
|
2012-03-02 06:28:38 +01:00
|
|
|
class Resetter
|
2011-04-13 00:14:00 +02:00
|
|
|
{
|
2011-09-12 18:28:59 +02:00
|
|
|
/**
|
|
|
|
* Index settings and mappings
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $indexConfigs;
|
2011-04-13 00:14:00 +02:00
|
|
|
|
2011-09-12 18:28:59 +02:00
|
|
|
public function __construct(array $indexConfigs)
|
2011-04-13 00:14:00 +02:00
|
|
|
{
|
2011-09-12 18:28:59 +02:00
|
|
|
$this->indexConfigs = $indexConfigs;
|
2011-04-13 00:14:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets all indexes
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
**/
|
|
|
|
public function reset()
|
|
|
|
{
|
2011-09-12 18:28:59 +02:00
|
|
|
foreach ($this->indexConfigs as $indexConfig) {
|
|
|
|
$indexConfig['index']->create($indexConfig['config'], true);
|
2011-04-13 00:14:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|