I have read that using fulltext searching is faster then using LIKE %%. I have updated my script but it always seems to always have 0 results.
SELECT *,
MATCH(pages) AGAINST('doodle') AS score
FROM books
WHERE MATCH(pages) AGAINST('doodle')
ORDER BY score DESC
The $keyword is longer then 4 chars and I have index the pages column as fulltext. I have "doodle" in the pages column in this format "yankee doodle".
I have also tried this
SELECT *,
MATCH(pages) AGAINST ('doodle' IN BOOLEAN MODE) AS score
FROM books
WHERE MATCH(pages) AGAINST ('doodle' IN BOOLEAN MODE)";
Neither of them works :\
Fulltext search has some bizarre quirks.
For example, the behaviour described in the last paragraphs of this page could be the reason for your problem:
.... for example, although the word “MySQL” is present in every row of the articles table shown earlier, a search for the word produces no results:
mysql> SELECT * FROM articles -> WHERE MATCH (title,body) AGAINST ('MySQL'); Empty set (0.00 sec)
The search result is empty because the word “MySQL” is present in at least 50% of the rows. As such, it is effectively treated as a stopword. For large data sets, this is the most desirable behavior: A natural language query should not return every second row from a 1GB table. For small data sets, it may be less desirable.
The answer here would be to add more rows, or use boolean search.
If you need weighted search results, check out the comment Posted by John Craig on December 16 2009 7:01pm
on the linked page for a workaround suggestion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With