Подтвердить что ты не робот

Полнотекстовый поиск MySQL с частичными словами

Полнотекстовый поиск MySQL выглядит превосходным и наилучшим способом поиска в SQL. Тем не менее, я, кажется, застрял в том, что он не будет искать частичные слова. Например, если у меня есть статья под названием "Учебник MySQL" и поиск "MySQL", она не найдет ее.

Проделав несколько поисков, я нашел различные ссылки на поддержку этого в MySQL 4 (я использую 5.1.40). Я пробовал использовать "MySQL" и "% MySQL%", но не работает (одна ссылка, которую я нашел, предположил, что это звезды, но вы можете сделать это только в конце или в начале не для обоих).

Вот моя структура таблицы и мой запрос, если кто-то может сказать мне, где я ошибаюсь, это было бы здорово. Я предполагаю, что частичное сопоставление слов построено каким-то образом.

CREATE TABLE IF NOT EXISTS `articles` (
  `article_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `article_name` varchar(64) NOT NULL,
  `article_desc` text NOT NULL,
  `article_link` varchar(128) NOT NULL,
  `article_hits` int(11) NOT NULL,
  `article_user_hits` int(7) unsigned NOT NULL DEFAULT '0',
  `article_guest_hits` int(10) unsigned NOT NULL DEFAULT '0',
  `article_rating` decimal(4,2) NOT NULL DEFAULT '0.00',
  `article_site_id` smallint(5) unsigned NOT NULL DEFAULT '0',
  `article_time_added` int(10) unsigned NOT NULL,
  `article_discussion_id` smallint(5) unsigned NOT NULL DEFAULT '0',
  `article_source_type` varchar(12) NOT NULL,
  `article_source_value` varchar(12) NOT NULL,
  PRIMARY KEY (`article_id`),
  FULLTEXT KEY `article_name` (`article_name`,`article_desc`,`article_link`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
INSERT INTO `articles` VALUES
(1, 'MySQL Tutorial', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 6, 3, 1, '1.50', 1, 1269702050, 1, '0', '0'),
(2, 'How To Use MySQL Well', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 1, 2, 0, '3.00', 1, 1269702050, 1, '0', '0'),
(3, 'Optimizing MySQL', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 0, 1, 0, '3.00', 1, 1269702050, 1, '0', '0'),
(4, '1001 MySQL Tricks', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 0, 1, 0, '3.00', 1, 1269702050, 1, '0', '0'),
(5, 'MySQL vs. YourSQL', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 0, 2, 0, '3.00', 1, 1269702050, 1, '0', '0'),
(6, 'MySQL Security', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'http://www.domain.com/', 0, 2, 0, '3.00', 1, 1269702050, 1, '0', '0');
SELECT count(a.article_id) FROM articles a

            WHERE MATCH (a.article_name, a.article_desc, a.article_link) AGAINST ('mysql')
            GROUP BY a.article_id
            ORDER BY a.article_time_added ASC

Префикс используется, поскольку он исходит от функции, которая иногда добавляет дополнительные объединения.

Как вы можете видеть, поиск MySQL должен возвращать счет 6, но, к сожалению, этого не делает.

Update

Нет результатов, которые возвращались, как каждая строка была сопоставлена.

http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html

"Результат поиска пуст, потому что слово" MySQL "присутствует не менее чем в 50% строк, поэтому оно эффективно рассматривается как стоп-слово. Для больших наборов данных это наиболее желательное поведение: A запрос на естественный язык не должен возвращать каждую вторую строку из таблицы 1 ГБ. Для небольших наборов данных это может быть менее желательным."

4b9b3361

Ответ 1

Я понимаю, что индексы MySQL FULLTEXT поддерживают только поиск префиксов (MATCH (a.article_name) AGAINST ('MySQL*' IN BOOLEAN MODE)).