mysql fulltext MATCH,AGAINST returning 0 results

匆匆过客 提交于 2019-12-31 03:26:06

问题


I am trying to follow: http://dev.mysql.com/doc/refman/4.1/en/fulltext-natural-language.html

in an attempt to improve search queries, both in speed and the ability to order by score.

However when using this SQL ("skitt" is used as a search term just so I can try match Skittles).

SELECT 
    id,name,description,price,image, 
    MATCH (name,description) 
    AGAINST ('skitt') 
    AS score 
FROM 
    products 
WHERE 
    MATCH (name,description)
AGAINST ('skitt')

it returns 0 results. I am trying to find out why, I think I might have set my index's up wrong I'm not sure, this is the first time I've strayed away from LIKE!

Here is my table structure and data:

Thank you!


回答1:


By default certain words are excluded from the search. These are called stopwords. "a" is an example of a stopword. You could test your query by using a word that is not a stopword, or you can disable stopwords:

  • How can I write full search index query which will not consider any stopwords?

If you want to also match prefixes use the truncation operator in boolean mode:

*

The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the * operator.



来源:https://stackoverflow.com/questions/3797932/mysql-fulltext-match-against-returning-0-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!