mysql php full text indexing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

mysql php full text indexing

Post 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');
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Re: mysql php full text indexing

Post 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";
Post Reply