我有一張桌子,我希望能做全文搜索,但我似乎無法得到我的搜索條件任何點擊。不能讓MySQL全文搜索工作
這裏是我的表是什麼樣子(我拿出行動,我相信都不重要了幾列):
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 | +-------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+
證明,有一排發現:
mysql> SELECT id, raw_content FROM transcripts;
+----+-------------+
| id | raw_content |
+----+-------------+
| 1 | foo |
+----+-------------+
而且這裏是我試圖讓搜索工作:
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)
我在做什麼錯?
默認全文忽略帶3個或更少字符的單詞 – Cfreak 2011-03-02 22:28:10
Bah,就是@Cfreak。你可以把它作爲答案嗎?布爾模式搜索使用更長的搜索。 – muirbot 2011-03-02 22:35:02
如果您搜索至少50%記錄中存在的單詞,請注意不使用布爾模式,將忽略它。更多信息在這裏http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html問候;) – 2011-03-02 22:39:38