From 12772ec35f5fb010b361b1dbc722928a9e25cb55 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 15 Jun 2011 08:39:02 -0700 Subject: [PATCH] Provide setup instructions for reducing minimum index word length Summary: The MySQL MyISAM fulltext backend defaults to a minimum length of 4, but many 3-letter words are useful search terms. Provide instructions for configuring MySQL to reduce the auto-stopword length. Test Plan: Followed instructions, searched for a 3-letter term and got a hit. Reviewed By: jungejason Reviewers: aran, tuomaspelkonen, jungejason CC: aran, jungejason Differential Revision: 471 --- src/infrastructure/setup/PhabricatorSetup.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/setup/PhabricatorSetup.php b/src/infrastructure/setup/PhabricatorSetup.php index c8f97b47e3..e6ea79149b 100644 --- a/src/infrastructure/setup/PhabricatorSetup.php +++ b/src/infrastructure/setup/PhabricatorSetup.php @@ -313,6 +313,27 @@ class PhabricatorSetup { self::write(" okay Database schema are up to date (v{$expect}).\n"); } + $index_min_length = queryfx_one( + $conn_raw, + 'SHOW VARIABLES LIKE %s', + 'ft_min_word_len'); + $index_min_length = idx($index_min_length, 'Value', 4); + if ($index_min_length >= 4) { + self::writeNote( + "MySQL is configured with a 'ft_min_word_len' of 4 or greater, which ". + "means you will not be able to search for 3-letter terms. Consider ". + "setting this in your configuration:\n". + "\n". + " [mysqld]\n". + " ft_min_word_len=3\n". + "\n". + "Then optionally run:\n". + "\n". + " REPAIR TABLE phabricator_search.search_documentfield QUICK;\n". + "\n". + "...to reindex existing documents."); + } + self::write("[OKAY] Database configuration OKAY\n"); @@ -457,8 +478,9 @@ class PhabricatorSetup { } private static function writeNote($note) { - self::write( - 'Note: '.wordwrap($note, 75, "\n ", true)."\n\n"); + $note = "*** NOTE: ".wordwrap($note, 75, "\n", true); + $note = "\n".str_replace("\n", "\n ", $note)."\n\n"; + self::write($note); } public static function writeHeader($header) {