ShadowZzz
ShadowZzz

Reputation: 415

Exclude any that are irrelevant from MYSQL full text search

I have a search query that looks like this:

  $sql="SELECT *, 
  MATCH(item_tags, item_name, item_description) AGAINST('$serchQuery' IN BOOLEAN MODE) AS score 
  FROM item_list 
  WHERE  `item_display`='1' OR `item_display`='3' AND MATCH(item_tags, item_name, item_description) AGAINST('$serchQuery' IN BOOLEAN MODE) ORDER BY score DESC LIMIT 0, 24";

It works fine (most of the time) but the problem I notice is that when you search a topic with limited results (lets say two), it will show those two first and the a bunch of non relevant ones until the limit is reached.

I want to know if there is a way to change the scoring system so it will determine that the two on top are the most relevant and the remaining are not relevant, so they should not be displayed.

Upvotes: 0

Views: 357

Answers (1)

grepsedawk
grepsedawk

Reputation: 3411

Well you could try:

$sql = "SELECT *,
MATCH (item_tags, item_name, item_description) AGAINST ($serchQuery IN BOOLEAN MODE) AS score 
FROM item_list 
WHERE MATCH(item_tags, item_name, item_description) AGAINST('$serchQuery' IN BOOLEAN MODE)  
HAVING score >= 1
ORDER BY score DESC LIMIT 0, 24";

Upvotes: 1

Related Questions