mysql全文返回空

ygya80vv  于 2021-06-17  发布在  Mysql
关注(0)|答案(2)|浏览(586)

我的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&nbsp;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&nbsp;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&nbsp;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

这是一把小提琴https://www.db-fiddle.com/f/jus9eabzjubl956wtntbqx/3
但它没有给我什么我哪里出错了我怎么能解决这个问题?

8wtpewkr

8wtpewkr1#

既然您在评论中要求它与MySQL5.5配合使用:
请看下面的代码db-fiddle.com/f/jus9eabzjubl956wtntbqx/3innodb不会工作它是myql版本<5.6
然后是两个不同的情况。对于MySQL5.7,非索引词列表仅适用。
但对于MySQL5.5,以下是两个原因:
这不起作用的第一个原因是,您要搜索的单词出现在总行数的50%或更多行中,因此它被认为是无效的 Common Word 结果不匹配。请参阅MySQL5.5全文搜索文档:
全文搜索有三种类型:
自然语言搜索将搜索字符串解释为自然人类语言中的短语(自由文本中的短语)。除了双引号(“)字符外,没有特殊运算符。非索引词列表适用。此外,出现在50%或更多行中的单词被认为是常见的,并且不匹配。
第二个原因是,默认情况下,全文搜索长度设置为4。所以你得换个地方 my.cnf 并增加价值:

[mysqld]
ft_min_word_len = 3

能够搜索3个字符的单词。
但是由于在db fiddle中我不能修改长度,这里是一个修改的工作fiddle,其中 Older 已使用。 Older 在50%的行中不存在,其长度为 >= 4 .

mpbci0fu

mpbci0fu2#

似乎是一个问题与全文停止字对myisam引擎,我改变了引擎到innodb,我可以得到结果。
查看此链接。全文停止字
要完全禁用stopwords,请添加以下内容 ft_stopword_file = '' ,修复表以重建索引, REPAIR TABLE tbl_name QUICK . 然后重新启动服务器

相关问题