[英]Implementing a tag system for my news system
我正在嘗試為我的新聞系統構建一個標簽系統。 我已經完成了這樣的表結構:
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表中的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");
還是使用LIKE和%通配符更好? 如果要使用全文搜索,我不確定是否應該為分數使用哪個閾值?
嘗試這個。
SELECT *
from article_tags
WHERE tag like '%$search%'
order by tag desc
要么
SELECT *
from article_tags
WHERE match(tag) against ('%$search%')
order by tag desc
還可以瀏覽此頁面,他們在其中談論全文搜索: http : //devzone.zend.com/26/using-mysql-full-text-searching/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.