本文整理汇总了PHP中Index::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::clean方法的具体用法?PHP Index::clean怎么用?PHP Index::clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::clean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_should_clean_old_indices
/**
* @test
*/
public function it_should_clean_old_indices()
{
/**
*
* Set
*
* @var \Mockery\Mock $index
* @var \Mockery\Mock $proxy
* @var \Mockery\Mock $client
*/
list($index, $proxy, $client) = $this->getMocks();
// Mock the self::$client variable
am::double('Iverberk\\Larasearch\\Index', ['self::$client' => $client]);
/**
*
* Expectation
*
*/
$client->shouldReceive('indices->getAliases')->andReturn(['index_123456789101112' => ['aliases' => []]]);
$client->shouldReceive('indices->delete')->with(['index' => 'index_123456789101112']);
/**
*
* Assertion
*
*/
Index::clean('index');
}
示例2: reindex
/**
* @param bool $relations
* @param int $batchSize
* @param array $mapping
* @param callable $callback
* @internal param bool $force
* @internal param array $params
*/
public function reindex($relations = false, $batchSize = 750, $mapping = [], callable $callback = null)
{
$model = $this->config['model'];
$name = $this->config['index']->getName();
$newName = $name . '_' . date("YmdHis");
$relations = $relations ? Config::get('larasearch::paths.' . get_class($model)) : [];
Index::clean($name);
$index = App::make('iverberk.larasearch.index', array('name' => $newName, 'proxy' => $this));
$index->create($mapping);
if ($index->aliasExists($name)) {
$index->import($model, $relations, $batchSize, $callback);
$remove = [];
foreach (Index::getAlias($name) as $index => $aliases) {
$remove = ['remove' => ['index' => $index, 'alias' => $name]];
}
$add = ['add' => ['index' => $newName, 'alias' => $name]];
$actions[] = array_merge($remove, $add);
Index::updateAliases(['actions' => $actions]);
Index::clean($name);
} else {
if ($this->config['index']->exists()) {
$this->config['index']->delete();
}
$actions[] = ['add' => ['index' => $newName, 'alias' => $name]];
Index::updateAliases(['actions' => $actions]);
$index->import($model, $relations, $batchSize, $callback);
}
Index::refresh($name);
}