MySQL Full Text Search Boolean Mode Partial Match

廉价感情. 提交于 2019-12-11 12:42:43

问题


I've found boolean mode of MySQL full text search useful, however there are a couple of things I can't seem to figure out how to achieve.

For instance imagine I have a full text column containing the words "Steve's Javascript Tutorial - Part One".

I would like to match this for each of the following searches: "tutorials", "javascript tutorials", "java", "java script", "script"

Imagine that each of those searches is simply assigned to a variable in whatever language may be being used (I always use PHP).

How could I modify this to make sure that Steve's article is returned on each of those searches?

MATCH (article_title) AGAINST ('"+$variable+"*' IN BOOLEAN MODE)


回答1:


This is impossible ;)

When you search for "tutorials" the entry will not be found, because the entry in the database is singular and the search term is plural. You should do some form of "word stemming" before inserting the values to the database (and on search).

When you have done this, your expression will work. For searrch terms with more words (spaces) you should add the asterix to every word.



来源:https://stackoverflow.com/questions/3047641/mysql-full-text-search-boolean-mode-partial-match

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