I have a table I want to bea ble to do fulltext searches on, but I can’t seem to get any hits on my search terms.
Here’s what my table looks like (I took out a few columns that I am confident are not important):
mysql> SHOW TABLE STATUS LIKE 'transcripts'; +-------------+--------+---------+------------+-------------------+----------+----------------+ | Name | Engine | Version | Row_format | Collation | Checksum | Create_options | +-------------+--------+---------+------------+-------------------+----------+----------------+ | transcripts | MyISAM | 10 | Dynamic | latin1_swedish_ci | NULL | | +-------------+--------+---------+------------+-------------------+----------+----------------+ mysql> DESCRIBE transcripts; +-------------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | content | text | YES | | NULL | | | raw_content | text | YES | MUL | NULL | | | tape_id | int(11) | YES | | NULL | | | state | int(11) | YES | | 0 | | | created_at | datetime | YES | | NULL | | | updated_at | datetime | YES | | NULL | | +-------------+----------+------+-----+---------+----------------+ mysql> SHOW INDEXES FROM transcripts; +-------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | +-------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+ | transcripts | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | transcripts | 1 | raw_content_index | 1 | raw_content | NULL | NULL | NULL | NULL | YES | FULLTEXT | +-------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+
Proof that there is a row to find:
mysql> SELECT id, raw_content FROM transcripts;
+----+-------------+
| id | raw_content |
+----+-------------+
| 1 | foo |
+----+-------------+
And here are my flailing attempts to get the search to work:
mysql> SELECT * FROM transcripts WHERE MATCH(raw_content) AGAINST ('foo');
Empty set (0.00 sec)
mysql> SELECT * FROM transcripts WHERE MATCH(raw_content) AGAINST ('foo' IN BOOLEAN MODE);
Empty set (0.00 sec)
mysql> SELECT id FROM transcripts WHERE MATCH(raw_content) AGAINST ('foo' IN NATURAL LANGUAGE MODE);
Empty set (0.00 sec)
mysql> SELECT * FROM transcripts WHERE MATCH(raw_content) AGAINST ('+foo*' IN BOOLEAN MODE);
Empty set (0.00 sec)
What am I doing wrong?
by default fulltext ignores words with 3 or less characters
(now posted as an answer by request 🙂 )