全文搜索不适用于数字

Rex*_*xha 2 mysql full-text-search

我有这张表,上面有歌名、艺术家等。

| id | artist | title | search_tags |

| 1 | miley cyrus | 23 | miley cyrus 23 |

这是我的查询:

select * from music where match(search_tags) against ('+$search_value*' IN BOOLEAN MODE)

当我搜索时它工作正常:miley但是当我搜索时它不显示任何结果search_tags = 23

注意:我在 Windows 10 和 InnoDB 上使用 MySQL 5.6 ft_min_word_len=1

Jay*_*len 5

搜索“23”时将不起作用,因为密钥的长度很小。MySQL 默认将键存储在全文索引中,最少 4 个字符。您需要将其更改为 1 或 2 才能使您的查询工作。

你需要在这里做的是

  1. 将此行添加到您的 my.ini 文件中

    innodb_ft_min_token_size = 1

  2. 重启 MySQL 服务

  3. 服务器恢复后,通过发出一个假的 ALTER 命令来重建你的表。

    ALTER TABLE table_name ENGINE=INNODB;

再次运行查询,它应该可以工作:)

祝你好运