Forum Moderators: coopster
Search: gold ring
So in priority search the database for "gold ring"
Then search the database for "gold" && not "gold ring" (so i dont get duplicates)
Then search the database for "ring" && not "gold ring" (so i dont get duplicates again)
finally get the results as one mysql result array. Is there any way to do this as a single mysql statment? Could you do this with a temporary table?
Thanks!
Ryan
Yes you are correct however I dont think that you would get the values in proper priority that way... for example: gold rings
I would want to show all instances of "gold rings" before any instances of just "gold" or "rings" because "gold rings" is a better match...
I'm pretty sure thats correct.
Thanks,
Ryan
$query = "SELECT MATCH(KWTitle) AGAINST('" . $keywords_commas . "') AS relevance_title,MATCH(KWDef) AGAINST('" . $keywords_commas . "') AS relevance_Def,KWTitle,KWDef,KWNumber,KWDate FROM db_mydb WHERE (MATCH(KWTitle) AGAINST ('" . $keywords_commas . "'))+(MATCH(KWDef) AGAINST('" . $keywords_commas . "')) ORDER BY relevance_title DESC,relevance_Def DESC LIMIT 0,100;"; I'd look at the MySQL manual for MATCH and relevance.
MySQL 4.0 has some new features that allows better searching, ranking so it is better if you use that.
The MATCH() function performs a natural language search for a string against a text collection. A collection is a set of one or more columns included in a FULLTEXT index. The search string is given as the argument to AGAINST(). For each row in the table, MATCH() returns a relevance value; that is, a similarity measure between the search string and the text in that row in the columns named in the MATCH() list.
[dev.mysql.com...]
create FULLTEXT INDEX name_index ON product (name,8);
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '8)' at line 2
Any ideas? Thanks