Jump to content
Larry Ullman's Book Forums

In Boolean Mode Finding Words Within Forum Posts


Recommended Posts

I am trying to implement a search feature to a forum I am creating and I want users to be able to search through posts. So far users type in the search terms in a form, and they go through to my $_GET['terms'].

 

The problem is that the IN BOOLEAN MODE search only returns posts that start with or end with one of the search terms users type into the form. I want it so that the search can also return phrases that are within posts, not necessarily starting or ending with. I have tried the boolean mode operators in all sorts of ways but it doesn't work. Is it possible to use fulltext searches in this way, or should I try a different method. 

Here is my Mysql query I am using:

 

$terms = mysqli_real_escape_string($dbc, htmlentities(strip_tags($_GET['terms'])));

 

$q = "SELECT m.message, m.posted_on, s.thread_id, s.subject FROM posts AS m LEFT JOIN threads AS s USING (thread_id) WHERE MATCH (message, subject) AGAINST('$terms*' IN BOOLEAN MODE)";

 

 

Link to comment
Share on other sites

I'd like to see you start providing a lot more information when you post. For example, the MySQL version, table type, and indexes established would be meaningful here. As would some specific examples of what you've tried, what should happen, and what does happen. Otherwise we're all just guessing blindly, which isn't good for anyone.

Link to comment
Share on other sites

 Share

×
×
  • Create New...