Jump to content

php & FULLTEXT


vicodin

Recommended Posts

ok im using this statement to search for things in mysql database...

$query =("SELECT * FROM products WHERE MATCH(keywords) AGAINST('$words')");

i got it to work by just spacing everything. Now my issue is if the i store the same word in another product neither product will show up. lets say i put in ARS8000 Sony TV and in another product i put ARS7000 Sony TV. It works if i put search ARS8000 or ARS7000 but not if i put Sony TV

Link to comment
Share on other sites

Heres the code...

function SearchIt($search){

   if (!empty($search)){

           $search = explode(" ",$search); 

                   mysql_select_db("mediapil_mkmdata") or die(mysql_error());

                           foreach($search as $words){

                                 $query =("SELECT * FROM products WHERE MATCH(keywords)           
AGAINST('$words')");

            $result = mysql_query($query) or die(mysql_error());
                
    while ($row = mysql_fetch_array($result)){
echo''my product output';
}
}
}
}


Link to comment
Share on other sites

Check this out:

 

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

 

A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in 50% or more of the rows are considered common and do not match. Full-text searches are natural language searches if no modifier is given.

 

So if this is on a test site and the only two rows you have contain "Sony TV" the above will hit true and not return any rows. I ran into this problem too a while ago.

Link to comment
Share on other sites

As far as I know it cannot be turned off as it is embedded into the binary portion of the code. It was designed that way so lets say you have 1,000 entries in your database, and you try to search for some common terms such as "sony" and "tv". If there are more than 500 records it does not return anything because of the possible toll on the server. Now take that a step up and imagine if you were searching millions of records.

 

Given that, it is a good design to prevent you from attempting to loop/cache about 500,000 records. The only way around it is to not use fulltext searching, or add bogus data so that the 50% mark isn't hit for testing purposes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.