【发布时间】:2013-08-13 14:43:06
【问题描述】:
我正在尝试为我的新闻系统构建一个标签系统。我已经完成了一个这样的表结构:
CREATE TABLE article_tags (
id int(11) unsigned NOT NULL auto_increment,
tag varchar (255) not null,
primary key (id));
CREATE TABLE article_tags_map (
id int(11) unsigned NOT NULL auto_increment,
tag_id int(11) unsigned not null,
article_id int(11) unsigned not null,
primary key (id));
现在我只是想知道在 article_tags 表的标签列中添加全文索引是否有意义?
$search = $_POST['search_string'];
$search_result = mysql_query ("SELECT *, MATCH(tag) AGAINST ($search) AS score
from article_tags
WHERE MATCH (tag) AGAINST($search)
order by score desc");
或者使用 LIKE 和 % 通配符会更好吗?如果我要使用全文搜索,我不确定我应该为分数使用什么阈值?
【问题讨论】:
标签: php mysql tags full-text-search