在mysql中用变音符号搜索阿拉伯语 [英] Searching arabic with diacritics in mysql
问题描述
所以我有一个巨大的带有变音符号的阿拉伯语书面文本数据库(变音符号是阿拉伯语中附加到其他字符的小字符)
So I have a huge database of Arabic written text with diacritics (diacritics are small characters in arabic that are attached to other characters)
例如:带有变音符号:وَهَكَذَا في كُلّ عَقْدٍ没有变音符号:وهكذا في كل عقد
e.g : with diacritic : وَهَكَذَا في كُلّ عَقْدٍ without diacritic : وهكذا في كل عقد
我正在使用 mysql 和 laravel 在文本中搜索没有变音符号的特定单词.
I am using mysql and laravel to search through the text for a specific word that has no diacritics.
如何忽略搜索中的变音符号?
How can I ignore the diacritics in the search ?
看起来像这样:
SELECT * FROM `LAWS` WHERE text = 'وهكذا في كل عقد'
但这不会:
SELECT * FROM `LAWS` WHERE text LIKE '%وهكذا في كل عقد%'
...
我正在使用 utf8_unicode_ci 并尝试了一些不同的排序规则,但它们似乎都不起作用!
I am using utf8_unicode_ci and I tried some different collations, but none of them seems to work !
如何让 mysql 中的 LIKE 语句像 = 一样工作?
How can I make the LIKE statement in mysql work similar to the = ?
推荐答案
使用utf8_general_ci";表LAWS"的归类类型以及表字段归类更改为utf8_general_ci".
Use "utf8_general_ci" collation type of table 'LAWS' and also table fields collations change to "utf8_general_ci".
这应该适用
SELECT * FROM `LAWS` WHERE text LIKE '%وهكذا في كل عقد%'
您需要管理阿拉伯语单词之间的空格的第二件事.您搜索的文本相同,但单词之间的空格不同.
喜欢在数据库中
وهكذا في كل عقد
但是搜索没有或更少的间距
But searching without or less spacing like
وهكذا في كل عقد
作为您搜索的最小字符串将返回更好的结果.
As smallest string you search will return better results.
这篇关于在mysql中用变音符号搜索阿拉伯语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!