MySQL全文搜索多个表并按相关性排序

时间:2012-02-12 07:40:25

标签: mysql full-text-search

我想通过4个表进行mysql全文搜索。它们都有相似的结构,所以我想在所有4中搜索TITLE和TEXT字段。我的查询看起来像这样:

    $result = mysql_query("(SELECT id, title, text, seo_url, image, 'news' as type,
MATCH(title,text) AGAINST ('$keyword' IN BOOLEAN MODE) AS relevance FROM gw_news WHERE MATCH(title,text)
AGAINST ('$keyword' IN BOOLEAN MODE) ORDER BY   relevance DESC) UNION (SELECT id, title, text,
seo_url, image, 'game-review' as type, MATCH(title,text) AGAINST ('$keyword' IN BOOLEAN MODE) AS
relevance FROM gw_game_review WHERE MATCH(title,text) AGAINST ('$keyword' IN BOOLEAN MODE) ORDER
BY relevance DESC) UNION (SELECT id, title, text, seo_url, image, 'hardware-review' as type, MATCH
(title,text) AGAINST ('$keyword' IN BOOLEAN MODE) AS relevance FROM gw_hardware_review WHERE MATCH
(title,text) AGAINST ('$keyword' IN BOOLEAN MODE ) ORDER BY relevance DESC) UNION (SELECT id,
title, text, seo_url, image, 'game-announcement' as type, MATCH(title,text) AGAINST ('$keyword' IN BOOLEAN MODE) AS relevance FROM  gw_game_announcement WHERE MATCH(title,text)
AGAINST ('$keyword' IN BOOLEAN MODE) ORDER BY relevance DESC)");

还有一个问题:目前我只得到完美匹配的结果,而不是“喜欢”的东西,所以我的搜索不太可靠。如何让它变得更好?感谢名单!

0 个答案:

没有答案