Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL fulltext search not working for some words like 'house'

I've setup a full text index on a small selection of records across 3 fields (tried a combination of the 3 as well and had the same result), and some words return results fine, but certain ones such as 'house' and 'australia' don't (interestingly, 'australian' and 'home' do).

It seems like odd behaviour. If I add "WITH QUERY EXPANSION" I get results, but they aren't the most relevant now.

Anyone got any idea why this is? Otherwise I'm going to have to resort to using LIKE searches, and I'd prefer to have relevancy included.

like image 330
Ninestein Avatar asked Jan 06 '11 07:01

Ninestein


People also ask

How do I create a full text search in MySQL?

The basic query format of full-text searches in MySQL should be similar to the following: SELECT * FROM table WHERE MATCH(column) AGAINST(“string” IN NATURAL LANGUAGE MODE); When MATCH() is used together with a WHERE clause, the rows are automatically sorted by the highest relevance first.

Does MySQL have full text search?

MySQL has support for full-text indexing and searching: A full-text index in MySQL is an index of type FULLTEXT . Full-text indexes can be used only with InnoDB or MyISAM tables, and can be created only for CHAR , VARCHAR , or TEXT columns.

Does InnoDB support full text?

Full-text indexes can be used only with MyISAM, Aria, InnoDB and Mroonga tables, and can be created only for CHAR, VARCHAR, or TEXT columns.

Can multi column fulltext indexes be used if so when?

The columns in the fulltext index can be placed in any sort of order, but all the columns as specified when creating the fulltext index must be referenced in the match() query.


1 Answers

It could be a couple of things:

  • MySQL has a default list of 'stop words' that aren't included in a full text search - http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html . 'house' and 'australia' don't seem to be in that list, but other words you search for might be affected by it.
  • Any word that appears in over 50% of the rows or is 3 letters or in less in length in the database is also considered a stop word. The 50% thing is particularly easy to be caught out by if you're just testing the full text search out on a table with only a few rows in.

If you search Google for "mysql stop words" you'll find a lot more about it, as it's one of those things that catches a lot of people out.

like image 54
Michael Low Avatar answered Oct 13 '22 00:10

Michael Low