我的mysql代码。
CREATE TABLE `videos` (
`id` int(50) NOT NULL,
`user_id` int(250) NOT NULL,
`title` varchar(250) NOT NULL,
`discription` text NOT NULL,
`video_path` varchar(250) NOT NULL,
`tumbnail_path` varchar(250) NOT NULL,
`paid` int(250) NOT NULL,
`date` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `videos` (`id`, `user_id`, `title`, `discription`, `video_path`, `tumbnail_path`, `paid`, `date`) VALUES
(1, 4, 'This is a new video', '<p>This is a new video from eduladder in at this video we are discribing how stuffs works</p>\r\n', 'uploadvid/xIdivzexFZXzr6bng2E9mU3PNvMVq0Iz.mp4', 'uploadthump/1AT1EsgJ--6iVLxEwEFRkWa9ADqqD1BG.jpg', 0, '2018-12-10'),
(2, 4, 'New Video for testig', '<p>This is a new video for testing purpose only</p>\r\n', 'uploadvid/_rsIHMc2giVoWV6aRixCoEUk0gKcDhDI.mp4', 'uploadthump/zA_t-2DMusUDvg9xVPwmRAn5-59He76-.jpg', 0, '2018-12-12'),
(3, 4, 'Some New Videos', '<p>This is a record of some new videos</p>\r\n', 'uploadvid/jPzlU3xSJaZVm7EzZu_JfaXq8kAK_1Vc.mp4', 'uploadthump/M_SZodSk20ba2FsXw3X1WVq7a48S_cj3.jpg', 0, '2018-12-13'),
(4, 4, 'Old video', '<p>This is an old video</p>\r\n', 'uploadvid/yaYiDBru2c7fCcosPmrj94JhZ5waxbu8.mp4', 'uploadthump/FhRXXen99DEa0d-8w5m2FDcvFyxlZgx4.png', 0, '2018-12-13'),
(5, 4, 'Almost new video and edited', '<p>This is about almost new video and editted version</p>\r\n', 'uploadvid/YOVPqiFO5xUnCtFAdYzgiY2wzsCnSQ11.mp4', 'uploadthump/MO1faxOKDNESee0gG5SQZYeantzlrPYM.png', 0, '2018-12-13');
ALTER TABLE `videos` ADD FULLTEXT(`title`,`discription`);我想问的问题就在这里。
SELECT * ,
MATCH (title, discription) AGAINST ('New') AS score
FROM videos
WHERE MATCH (title, discription) AGAINST ('New')
ORDER BY score
DESC LIMIT 20这里有一个mysql小提琴https://www.db-fiddle.com/f/jUs9EABZjuBL956WtnTbqx/3
但这并没有给我带来什么错误,我该如何解决这个问题呢?
发布于 2018-12-13 05:27:31
似乎是一个问题的全文停止字在myisam引擎,我改变引擎为InnoDB,我可以得到结果。
看这个链接。全文词组
若要完全禁用秒表,请将此ft_stopword_file = ''添加到数据库配置文件中,修复要重新生成索引的表REPAIR TABLE tbl_name QUICK。并重新启动服务器
发布于 2018-12-13 07:03:02
因为您要求它在您的评论中使用MySql 5.5:
请参阅udated代码db-fiddle.com/f/jUs9EABZjuBL956WtnTbqx/3
那就是两个不同的案子。对于MySql 5.7,Stopword列表仅适用。
但是,对于MySql 5.5,从您的最新小提琴这里有两个原因:
这不起作用的第一个原因是因为您正在搜索的单词存在于50%或更多的行中,因此它被认为是Common Word,因此不会匹配。请参阅MySQL5.5 FullText搜索文档:
全文搜索有三种类型: 自然语言搜索将搜索字符串解释为自然人类语言中的短语(自由文本中的短语)。除了双引号(")字符外,没有特殊的运算符。应用停止字列表。此外,50%或50%以上的行中存在的单词被认为是常见的,并且不匹配。
第二个原因是,默认情况下,FullText搜索长度设置为4。因此,您需要在my.cnf中更改它并添加值:
[mysqld]
ft_min_word_len = 3能够搜索三个字符的单词。
但是,由于在数据库中,我不能修改长度,这里是一个改良工作小提琴,其中使用了单词Older。Older不存在于50%的行上,其长度为>= 4。
https://stackoverflow.com/questions/53755204
复制相似问题