开发者

Search mechanism to search for words both with/without special characters - how to?

开发者 https://www.devze.com 2023-03-20 03:08 出处:网络
How to make a search mechanism like that: when user type: \"sól\" two words are searched: \"sol\" & \"sól\"开发者_StackOverflow社区

How to make a search mechanism like that:

when user type: "sól" two words are searched: "sol" & "sól"

开发者_StackOverflow社区

and there are search results for both words


You can use a mySQL collation that is "Umlaut insensitive", for example utf8_general_ci.

Either

  • Create a specialized search column that is utf8_general_ci
  • Or define the collation while searching, which is easier but less good for performance. This should work:

    select * from column where name='sól' COLLATE utf8_general_ci;
    

    However, doing this may degrade performance in some situations, because I'm quite sure the fulltext index can't be used when specifying the collation like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消