morphboy23 Posted July 10, 2007 Share Posted July 10, 2007 I know in boolean mode, you can put > and < in front of search terms to increase or decrease the weight of that term in the search result. But is there any way to weigh the term based on what column it was found in? Example: Say I have a table with FULLTEXT(keywords, title, text). Can I have it weigh terms found in 'keywords' more than keywords found in the other two? Quote Link to comment https://forums.phpfreaks.com/topic/59202-solved-any-way-to-make-fulltext-weigh-columns-differently/ Share on other sites More sharing options...
Wildbug Posted July 10, 2007 Share Posted July 10, 2007 I don't believe you can. What you can do is search the keywords column seperately and add it to or multiply it by the FULLTEXT score. SELECT title, MATCH(title, text) AGAINST (('foo +bar' IN BOOLEAN MODE)) + 2 * (keywords LIKE '%foo%' + keywords LIKE '%bar%') AS score FROM table WHERE MATCH(title, text) AGAINST ('foo +bar' IN BOOLEAN MODE) AND (keywords LIKE '%foo%' OR keywords LIKE '%bar%') ORDER BY score DESC, title; You could even parse the query string in PHP and add even more weight to keywords preceeded by a "+". Quote Link to comment https://forums.phpfreaks.com/topic/59202-solved-any-way-to-make-fulltext-weigh-columns-differently/#findComment-294257 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.