简体   繁体   English

为我的新闻系统实现标签系统

[英]Implementing a tag system for my news system

I'm trying to build a tag system for my news system. 我正在尝试为我的新闻系统构建一个标签系统。 I have finalized a table structure like this: 我已经完成了这样的表结构:

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));

Now I'm just wondering if it would make sense to add a full text index to the tag column in article_tags table ? 现在,我只是想知道是否将全文索引添加到article_tags表中的tag列是否有意义?

$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");

Or would I be better off with using LIKE and % wildcard characters ? 还是使用LIKE和%通配符更好? If I were to use fulltext search, I'm not really sure what threshold should I use for the score ? 如果要使用全文搜索,我不确定是否应该为分数使用哪个阈值?

Try this. 尝试这个。

SELECT *
from article_tags
WHERE tag like '%$search%'
order by tag desc

or 要么

 SELECT *
    from article_tags
    WHERE match(tag) against ('%$search%')
    order by tag desc

also take a look to this page where they talk about full text searching: http://devzone.zend.com/26/using-mysql-full-text-searching/ 还可以浏览此页面,他们在其中谈论全文搜索: http : //devzone.zend.com/26/using-mysql-full-text-searching/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM