问题
I set up a MyISAM table to do FULLTEXT searching. I do not want searches to be case-sensitive.
My searches are along the lines of:
SELECT * FROM search WHERE MATCH (keywords) AGAINST ('+diversity +kitten' IN BOOLEAN MODE);
Let's say the keywords field I'm looking for has the value "my Diversity kitten".
I noticed the searches were case-sensitive. I double-checked my collation on the search table, it was set to utf8_bin. D'oh! I changed it to utf8_general_ci.
But my query is still case-sensitive! Why?
Is there a server setting I need to change, too?
Is there something I need to do besides change the collation?
I did a "REPAIR TABLE search QUICK" to rebuild the FULLTEXT index, but that didn't do it either...
My searches are still case-sensitive. =(
回答1:
Aha, figured it out for reals this time.
I believe my issue was using NaviCat to update the collation. I have an older version of NaviCat, maybe it was a bug or something.
Doing:
ALTER TABLE search CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
fixed it correctly.
Always use command line, kids! =)
回答2:
Hmm - that behavior doesn't match the manual:
By default, the search is performed in case-insensitive fashion. However, you can perform a case-sensitive full-text search by using a binary collation for the indexed columns. For example, a column that uses the
latin1
character set of can be assigned a collation oflatin1_bin
to make it case sensitive for full-text searches.
Which version of MySQL do you use? Can you provide some data that would allow replicating the problem on another machine?
来源:https://stackoverflow.com/questions/4945349/mysql-search-with-uft8-general-ci-is-case-sensitive-for-fulltext