From 6d203d42e92ec16c2dfbad801de938598c94bab7 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Sat, 8 Aug 2020 18:08:06 +0300 Subject: [PATCH] [DATABASE] Enable fulltext search by default Also rename fulltext indices to more fitting names and move the check from classes into database/schema.php --- DOCUMENTATION/SYSTEM_ADMINISTRATORS/CONFIGURE.md | 8 +++----- classes/Notice.php | 9 ++++----- classes/Profile.php | 11 ++++------- lib/database/mysqlschema.php | 5 ----- lib/database/schema.php | 4 ++++ lib/util/default.php | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/DOCUMENTATION/SYSTEM_ADMINISTRATORS/CONFIGURE.md b/DOCUMENTATION/SYSTEM_ADMINISTRATORS/CONFIGURE.md index 5aca66a15b..4d155fb300 100644 --- a/DOCUMENTATION/SYSTEM_ADMINISTRATORS/CONFIGURE.md +++ b/DOCUMENTATION/SYSTEM_ADMINISTRATORS/CONFIGURE.md @@ -744,11 +744,9 @@ search Some stuff for search. * `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 - but requires the lame old MyISAM engine for MySQL. The latter - will work with InnoDB but could be miserably slow on large - systems. We'll probably add another type sometime in the future, - with our own indexing system (maybe like MediaWiki's). + be 'like' or 'fulltext' (default). The latter is faster and more efficient + but if your storage engine of choice does not support it, then feel free to + choose 'like', but it could be miserably slow on large databases. sessions diff --git a/classes/Notice.php b/classes/Notice.php index bab09cee84..3ddb7b5526 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -115,13 +115,12 @@ class Notice extends Managed_DataObject 'notice_verb_idx' => array('verb'), 'notice_url_idx' => array('url'), // Qvitter wants this '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; } diff --git a/classes/Profile.php b/classes/Profile.php index 47f4824acd..9833c024f2 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -62,15 +62,12 @@ class Profile extends Managed_DataObject 'primary key' => array('id'), 'indexes' => array( '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; } diff --git a/lib/database/mysqlschema.php b/lib/database/mysqlschema.php index b9d4ca2ccb..a35f474f6f 100644 --- a/lib/database/mysqlschema.php +++ b/lib/database/mysqlschema.php @@ -370,11 +370,6 @@ class MysqlSchema extends Schema public function preferredEngine($def) { - /* MyISAM is no longer required for fulltext indexes, fortunately - if (!empty($def['fulltext indexes'])) { - return 'MyISAM'; - } - */ return 'InnoDB'; } diff --git a/lib/database/schema.php b/lib/database/schema.php index f472388bd7..b5d34dce2b 100644 --- a/lib/database/schema.php +++ b/lib/database/schema.php @@ -1061,6 +1061,10 @@ class Schema } } + if (common_config('search', 'type') !== 'fulltext') { + unset($tableDef['fulltext indexes']); + } + return $tableDef; } diff --git a/lib/util/default.php b/lib/util/default.php index 7cf14ae7d0..58a46400b2 100644 --- a/lib/util/default.php +++ b/lib/util/default.php @@ -301,7 +301,7 @@ $default = 'allow_tagging' => array('all' => true), // equivalent to array('local' => true, 'remote' => true) 'desclimit' => null), 'search' => - array('type' => 'like'), + array('type' => 'fulltext'), 'sessions' => array('handle' => false, // whether to handle sessions ourselves 'debug' => false, // debugging output for sessions