Re: FULLTEXT and LIKE
| From: | Ognyan Bankov | Date: | Fri, 23 Jul 2004 08:50:29 +0000 |
| Subject: | Re: FULLTEXT and LIKE | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35442@lists.php.net to get a copy of this message | ||
may be the best solution is combination of A) and B)
check the length of the phrase if it is <=3 use B) (it will be damn slow if you have great number of rows in 'news' table and/or 'content' is big most of the times)
if it is > 3 use A)
B.R.
Ognyan
Monty wrote:
Hi, My head is swimming with lots of info gleaned from various newsgroups about using fulltext indexes in MySQL, but, I'm still not sure what the best solution would be for what I want to do. I'm concerned about the 3-char minimum and not being able to search on partial words (my version of MySQL doesn't support boolean fulltext searches). I have a simple News table that is structured like this: CREATE TABLE-- Ognyan Bankov ogre_bank@yahoo.com metatotem.comnews(idint(7) unsigned NOT NULL auto_increment,authorvarchar(50) NOT NULL default '',headlinevarchar(60) NOT NULL default '',contenttext NOT NULL,urltext NOT NULL, UNIQUE KEYid(id), ) TYPE=MyISAM; I want searches for News to be on the author, headline and content fields. What is the best way to index and search this? A) Create a combined fulltext index: FULLTEXT (author,headline,content) -- and do searches using MATCH() and AGAINST(). B) Create a fulltext index only for the content field and use this kind of select: SELECT * FROM db WHERE author LIKE "%phrase%" OR headline LIKE "%phrase%" OR MATCH(content) AGAINST(phrase); C) None of the above ... is there a better way? Thanks a lot for any input or feedback! I'm completely lost! Monty