MySQL - Match(...)反对(...)返回空数组

时间:2014-11-21 12:42:37

标签: php mysql sql phpmyadmin full-text-search

我正在研究我网站上的搜索功能,并希望稍微改进一下。

我的网站是一个管网站。

我曾经使用过mysql' LIKE'声明,但实现了MATCH()AGAINST()更高效。

但我仍有小问题和部分问题。

让我们说视频数据库中有一个名为:'关于猴子的有趣视频 - 亚洲 - 大声笑'

有不同的选择查询与将返回的内容(使用phpmyadmin以避免错误与错误的PHP代码相关)

SELECT video.*, MATCH (title) AGAINST ('lol' IN BOOLEAN MODE) AS relevance FROM video WHERE active = '1' AND MATCH (title) AGAINST ('lol' IN BOOLEAN MODE) ORDER BY relevance DESC LIMIT 18
returns
nothing

SELECT video.*, MATCH (title) AGAINST ('monkey' IN BOOLEAN MODE) AS relevance FROM video WHERE active = '1' AND MATCH (title) AGAINST ('monkey' IN BOOLEAN MODE) ORDER BY relevance DESC LIMIT 18
returns 
nothing

SELECT video.*, MATCH (title) AGAINST ('asia' IN BOOLEAN MODE) AS relevance FROM video WHERE active = '1' AND MATCH (title) AGAINST ('asia' IN BOOLEAN MODE) ORDER BY relevance DESC LIMIT 18
returns
the video in the database

SELECT video.*, MATCH (title) AGAINST ('asian monkey' IN BOOLEAN MODE) AS relevance FROM video WHERE active = '1' AND MATCH (title) AGAINST ('asian monkey' IN BOOLEAN MODE) ORDER BY relevance DESC LIMIT 18
returns
nothing

所以如果我是对的,视频只有在包含确切的单词时才返回,如果该单词至少有4个字符。

但奇怪的是,' ft min word len'设置为2,因此查询“lol'应该返回视频。此外,查询说明“在布尔模式”中。所以我想它应该返回公共话语。

从像“猴子”这样的部分词汇来看我不知道如何使用' LIKE%...%或LIKE%...%'而不是' monkeys'不会成为一个解决方案,因为我需要获得相关性。

非常感谢您阅读并帮助我。

0 个答案:

没有答案