本文整理汇总了PHP中Index::refresh方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::refresh方法的具体用法?PHP Index::refresh怎么用?PHP Index::refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::refresh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_should_refresh
/**
* @test
*/
public function it_should_refresh()
{
/**
*
* 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->refresh')->with(['index' => 'mock']);
/**
*
* Assertion
*
*/
Index::refresh('mock');
}
示例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);
}
示例3: testSetTypeFullText
/**
* Tests to add an Index to a Column with Type Fulltext
*/
public function testSetTypeFullText()
{
// Create index
$index = new Index();
$index->TABLE_NAME = 'table2';
$index->TABLE_SCHEMA = 'indextest';
$index->INDEX_NAME = 'newname';
$index->setType('FULLTEXT');
// Add new column
$columns = $index->columns;
$col = new IndexColumn();
$col->COLUMN_NAME = 'pk';
$columns[] = $col;
$col = new IndexColumn();
$col->COLUMN_NAME = 'varchar';
$col->SUB_PART = 10;
$columns[] = $col;
$index->columns = $columns;
// Try saving
$index->save();
// Reload index and load index columns
$index->refresh();
$cols = IndexColumn::model()->findAllByAttributes(array('TABLE_SCHEMA' => $index->TABLE_SCHEMA, 'TABLE_NAME' => $index->TABLE_NAME, 'INDEX_NAME' => $index->INDEX_NAME));
// Check properties
$this->assertEquals('newname', $index->INDEX_NAME);
$this->assertEquals('FULLTEXT', $index->getType());
}
示例4: setUp
protected function setUp()
{
parent::setUp();
$this->_index = $this->_createIndex("rescore_test");
$this->_index->refresh();
}