views:

218

answers:

1

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)

A: 

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.

Tobias P.
Imagine a scenario where a user has input the text into a search form. Using a star between each word would work for "java script". However imagine they are searching for "London Paris" this would need to return "My trip from London to Paris" as well as "My trip from Paris to London". So using London*Paris wouldn't work. Instead what would be needed is +london+paris. But of course that wouldn't work for the "+java+script" example. Is there no way to cater for both examples, given that this would be used on user input.
Rob
When a user submits a word which is incorrectly spelled (space between Java and Script) you have no way to correct it with mysql boolean mode.You would have to implement spell checking or use fuzzy searching, but fuzzy search is not possible with MySQL
Tobias P.