コード例 #1
0
ファイル: IndexTest.php プロジェクト: geekybeaver/larasearch
 /**
  * @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
0
ファイル: Proxy.php プロジェクト: geekybeaver/larasearch
 /**
  * @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
0
ファイル: IndexTest.php プロジェクト: cebe/chive
 /**
  * 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
0
 protected function setUp()
 {
     parent::setUp();
     $this->_index = $this->_createIndex("rescore_test");
     $this->_index->refresh();
 }