Page 1 of 1

mysql php full text indexing

Posted: Thu Jan 28, 2010 7:17 pm
by scarface222
Hey guys I am trying to do a quick search using mysql fulltext table fields and php, since I heard full text makes searched more efficient rather than using the 'like' term.

I tried this statement and I didn't get any results even though there are about 10 other topics with the exact same title ($title). Am I doing something wrong or missing something? I thought I understood full text but apparently not lol. I do not get any mysql error, I just get 0 results. Also, I tried only matching topic_title against $title and get nothing. IF anyone has used this before and can give me any tips I would really appreciate it.

Code: Select all

$query="SELECT *,
                MATCH(topic_title, description) AGAINST('$title') AS score
                FROM topic
            WHERE MATCH(topic_title, description) AGAINST('$title')
            ORDER BY score DESC LIMIT 10";
$result1=mysql_query($query) or die('Error, select query failed');

Re: mysql php full text indexing

Posted: Thu Jan 28, 2010 8:50 pm
by scarface222
I changed it to this (boolean mode) and I get results when the exact same match occurs, but if I type 3 letters out of 4 it is not considered a match. I have another script that can give these types of results but I was hoping I could do that in a query instead of going through multiple steps. IS this possible using this mysql syntax?

Code: Select all

$query="SELECT *,
                MATCH(topic_title, description) AGAINST('$title' IN BOOLEAN MODE) AS score
                FROM topic
            WHERE MATCH(topic_title, description) AGAINST('$title' IN BOOLEAN MODE)
            ORDER BY score DESC LIMIT 10";