resource = $resource; $this->indexScopeResolver = $indexScopeResolver; } /** * @inheritdoc */ public function delete($index, array $dimensions = []) { $tableName = $this->indexScopeResolver->resolve($index, $dimensions); if ($this->resource->getConnection()->isTableExists($tableName)) { $this->resource->getConnection()->dropTable($tableName); } } /** * @inheritdoc */ public function create($index, array $fields, array $dimensions = []) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); } /** * Create fulltext index table. * * @param string $tableName * @throws \Zend_Db_Exception * @return void */ protected function createFulltextIndex($tableName) { $table = $this->resource->getConnection()->newTable($tableName) ->addColumn( 'entity_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false], 'Entity ID' )->addColumn( 'attribute_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false] )->addColumn( 'data_index', Table::TYPE_TEXT, '4g', ['nullable' => true], 'Data index' )->addIndex( 'idx_primary', ['entity_id', 'attribute_id'], ['type' => AdapterInterface::INDEX_TYPE_PRIMARY] )->addIndex( 'FTI_FULLTEXT_DATA_INDEX', ['data_index'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT] ); $this->resource->getConnection()->createTable($table); } }