suttercain Posted May 19, 2009 Share Posted May 19, 2009 Hi everyone, I have done full text searches in the past but it's been a while. I created three columns. id, title and body. The table is MyISAM and the title and body columns have been set to 'FULL TEXT' to allow the search to work. Here is the basic code I am using to get this going: <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="search" id="search" /><input type="submit" name="submit" /> </form> <?php if (isset($_POST['search'])) { include('connection.php'); $search = mysql_real_escape_string(trim($_POST['search'])); $sql = "SELECT id, title, MATCH (title, body) AGAINST ('".$search."') AS score FROM faq WHERE MATCH (title, body) AGAINST ('".$search."')"; $res = mysql_query($sql) or die(mysql_error()); unset($_POST['search']); }//end if ?> </body> When I run this code I get the following MySQL error code: Can't find FULLTEXT index matching the column list. Any suggestions? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/ Share on other sites More sharing options...
fenway Posted May 19, 2009 Share Posted May 19, 2009 Did you make a single fulltext index on all 3 columns, of a fulltext index on each column? You need the former, not the latter. Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/#findComment-837434 Share on other sites More sharing options...
suttercain Posted May 19, 2009 Author Share Posted May 19, 2009 Thanks Fenway. That solved that issue But now when I run the following code I don't get any results: <?php $sql = "SELECT body, title FROM faq1 WHERE MATCH (body, title) AGAINST ('vehicles')"; ?> But this code does work, but is not a full-text search: <?php $sql = "SELECT * FROM faq1 WHERE title LIKE '%Vehicles%'"; ?> What am I doing wrong in the first query statement? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/#findComment-837480 Share on other sites More sharing options...
fenway Posted May 19, 2009 Share Posted May 19, 2009 If you read the refman page on FULLTEXT, you'll see that it doesn't always return "everything" you would expect. If you don't have a large record set, of if your query matches too many records, you'll get unexpected output. Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/#findComment-837496 Share on other sites More sharing options...
suttercain Posted May 19, 2009 Author Share Posted May 19, 2009 Thanks Fenway, I have 6 records I am trying to query at the moment with more to be added once I validate this works. I am concerned about the "too many" statement you quoted. That's scary because people may not find what they want. "doesn't always return "everything" you would expect" makes me wonder if I should use this form of search because that seems like a big pit fall. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/#findComment-837502 Share on other sites More sharing options...
fenway Posted May 20, 2009 Share Posted May 20, 2009 FULLTEXT search as handled natively by mysql is basically broken... sphinx is much, much better. Quote Link to comment https://forums.phpfreaks.com/topic/158773-solved-full-text-search-error-cant-find-fulltext-index-matching-the-column-list/#findComment-838098 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.