2017-04-07 6 views

답변

0

전체 텍스트 검색은 MyISAM에서만 가능합니다. 이것은 MyISAM이 InnoDB에 가지고있는 주요 이점 중 하나입니다. 관련 : https://dba.stackexchange.com/questions/1/what-are-the-main-differences-between-innodb-and-myisam

+1

예, InnoDB하지만 MySQL의 v5.6에까지이를 지원하지 않았다. 그러나, 5.6 이상 mysql 버전. 전체 텍스트 검색을 지원합니다. – Vishal

+1

모든 테이블을 InnoDB에 저장해야하는 이유는 AWS의 자동 백업에 문제가 발생할 수 있기 때문입니다. http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#Overview.BackupDeviceRestrictions – Vishal

5

InnoDB는 MySQL 버전 5.6 이후로 Fulltext 검색을 지원하지만, 프레임 워크와 함께 제공되는 MySQLSchemaManager은 fulltext 인덱스가 정의 된 테이블에서 InnoDB를 사용하지 못하도록합니다. 아마도 GitHub에서 문제를 제기 할 수 있습니다.

# Compare this to https://github.com/silverstripe/silverstripe-framework/blob/3.5/model/connect/MySQLSchemaManager.php#L100 
class MyCustomSchemaManager extends MySQLSchemaManager 
{ 

    public function alterTable($tableName, $newFields = null, $newIndexes = null, $alteredFields = null, 
           $alteredIndexes = null, $alteredOptions = null, $advancedOptions = null 
    ) { 
     if ($this->isView($tableName)) { 
      $this->alterationMessage(
       sprintf("Table %s not changed as it is a view", $tableName), 
       "changed" 
      ); 
      return; 
     } 
     $alterList = array(); 

     if ($newFields) { 
      foreach ($newFields as $k => $v) { 
       $alterList[] .= "ADD \"$k\" $v"; 
      } 
     } 
     if ($newIndexes) { 
      foreach ($newIndexes as $k => $v) { 
       $alterList[] .= "ADD " . $this->getIndexSqlDefinition($k, $v); 
      } 
     } 
     if ($alteredFields) { 
      foreach ($alteredFields as $k => $v) { 
       $alterList[] .= "CHANGE \"$k\" \"$k\" $v"; 
      } 
     } 
     if ($alteredIndexes) { 
      foreach ($alteredIndexes as $k => $v) { 
       $alterList[] .= "DROP INDEX \"$k\""; 
       $alterList[] .= "ADD " . $this->getIndexSqlDefinition($k, $v); 
      } 
     } 

     $dbID = self::ID; 
     if ($alteredOptions && isset($alteredOptions[$dbID])) { 
      $this->query(sprintf("ALTER TABLE \"%s\" %s", $tableName, $alteredOptions[$dbID])); 
      $this->alterationMessage(
       sprintf("Table %s options changed: %s", $tableName, $alteredOptions[$dbID]), 
       "changed" 
      ); 
     } 

     $alterations = implode(",\n", $alterList); 
     $this->query("ALTER TABLE \"$tableName\" $alterations"); 
    } 

} 

는 그런 다음 사용자 정의 클래스 사용 Injector를 사용할 수 있습니다 : 당신은 (MySQLSchemaManager 및 재정의 alterTable()을 확장하여)이 제한없이 자신의 SchemaManager를 만들 수 있습니다

# Config.yml 
Injector: 
    MySQLSchemaManager: 
    class: MyCustomSchemaManager 

을 이제 사용할 수 있어야합니다 정적 인 create_table_options은 InnoDB 엔진을 강제하고, indexes 정적을 통해 전체 텍스트 인덱스를 생성합니다.

예 :

# SomePage.php  

/** 
* Force InnoDB database engine. 
* 
* @var array 
*/ 
private static $create_table_options = [ 
    'MySQLDatabase' => 'ENGINE=InnoDB' 
]; 

/** 
* Define what fulltext indexes to create. 
* 
* @var array 
*/ 
private static $indexes = [ 
    'SearchFields' => [ 
     'type' => 'fulltext', 
     'name' => 'SearchFields', 
     'value' => '"MyField", "Tags"', 
    ] 
];