[DATABASE] Enable fulltext search by default

Also rename fulltext indices to more fitting names
and move the check from classes into database/schema.php
This commit is contained in:
Alexei Sorokin 2020-08-08 18:08:06 +03:00 committed by Diogo Peralta Cordeiro
parent 974404bcfd
commit 6d203d42e9
6 changed files with 16 additions and 23 deletions

View File

@ -744,11 +744,9 @@ search
Some stuff for search. Some stuff for search.
* `type`: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either * `type`: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
be 'fulltext' or 'like' (default). The former is faster and more efficient be 'like' or 'fulltext' (default). The latter is faster and more efficient
but requires the lame old MyISAM engine for MySQL. The latter but if your storage engine of choice does not support it, then feel free to
will work with InnoDB but could be miserably slow on large choose 'like', but it could be miserably slow on large databases.
systems. We'll probably add another type sometime in the future,
with our own indexing system (maybe like MediaWiki's).
sessions sessions

View File

@ -115,13 +115,12 @@ class Notice extends Managed_DataObject
'notice_verb_idx' => array('verb'), 'notice_verb_idx' => array('verb'),
'notice_url_idx' => array('url'), // Qvitter wants this 'notice_url_idx' => array('url'), // Qvitter wants this
'notice_reply_to_idx' => array('reply_to') 'notice_reply_to_idx' => array('reply_to')
) ),
'fulltext indexes' => array(
'notice_fulltext_idx' => array('content'),
),
); );
if (common_config('search', 'type') == 'fulltext') {
$def['fulltext indexes'] = array('content' => array('content'));
}
return $def; return $def;
} }

View File

@ -62,15 +62,12 @@ class Profile extends Managed_DataObject
'primary key' => array('id'), 'primary key' => array('id'),
'indexes' => array( 'indexes' => array(
'profile_nickname_idx' => array('nickname'), 'profile_nickname_idx' => array('nickname'),
) ),
'fulltext indexes' => array(
'profile_fulltext_idx' => array('nickname', 'fullname', 'location', 'bio', 'homepage'),
),
); );
// Add a fulltext index
if (common_config('search', 'type') == 'fulltext') {
$def['fulltext indexes'] = array('nickname' => array('nickname', 'fullname', 'location', 'bio', 'homepage'));
}
return $def; return $def;
} }

View File

@ -370,11 +370,6 @@ class MysqlSchema extends Schema
public function preferredEngine($def) public function preferredEngine($def)
{ {
/* MyISAM is no longer required for fulltext indexes, fortunately
if (!empty($def['fulltext indexes'])) {
return 'MyISAM';
}
*/
return 'InnoDB'; return 'InnoDB';
} }

View File

@ -1061,6 +1061,10 @@ class Schema
} }
} }
if (common_config('search', 'type') !== 'fulltext') {
unset($tableDef['fulltext indexes']);
}
return $tableDef; return $tableDef;
} }

View File

@ -301,7 +301,7 @@ $default =
'allow_tagging' => array('all' => true), // equivalent to array('local' => true, 'remote' => true) 'allow_tagging' => array('all' => true), // equivalent to array('local' => true, 'remote' => true)
'desclimit' => null), 'desclimit' => null),
'search' => 'search' =>
array('type' => 'like'), array('type' => 'fulltext'),
'sessions' => 'sessions' =>
array('handle' => false, // whether to handle sessions ourselves array('handle' => false, // whether to handle sessions ourselves
'debug' => false, // debugging output for sessions 'debug' => false, // debugging output for sessions