如何实现SQLite中的重音/音调符号不敏感的搜索? [英] How to implement the accent/diacritic insensitive search in Sqlite?

查看:231
本文介绍了如何实现SQLite中的重音/音调符号不敏感的搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法做到在sqlite的口音/音调符号不敏感的搜索

Is there a way to do an accent/diacritic insensitive search in sqlite?

谷歌搜索,我发现的这个,但我真心不知道如何创建我的在C#中排序函数。我想如果你正在使用System.Data.Sqlite创建PT-BR整理SQLite的...

Googling, I've found this, but I sincerely don't know how to create my "collation function" in C#. I'm trying create the pt-br collation for Sqlite...

推荐答案

可以使用自定义排序顺序,并修改它为您的需求?一个例子:

If you are using System.Data.Sqlite you can use a custom collation sequence and modify it for your needs ... an example:

/// <summary>
/// User-defined collating sequence using the current UI culture.
/// </summary>
[SQLiteFunction(Name = "MYSEQUENCE", FuncType = FunctionType.Collation)]
class MySequence : SQLiteFunction
{
  public override int Compare(string param1, string param2)
  {
    return String.Compare(param1, param2, true);
  }
}

您的SQL查询使用上面的威力自定义排序顺序是这样的:
SELECT * FROM MyTable的ORDER BY MyChineseColumn COLLATE MYSEQUENCE DESC

Your SQL query to use the custom collation sequence above might look like this: SELECT * FROM MyTable ORDER BY MyChineseColumn COLLATE MYSEQUENCE DESC

(来源:的http://sqlite.phxsoftware.com/forums/p/862/3779.aspx#3779

您只可以设置在创建表的整理和建立在该列的索引。
但是要记住,你将无法从那里没有定义排序规则以外的SQLite引擎访问表。

You just can set collation at table creation and build indices on that column. But remember, you won't be able to access table from other sqlite engine where collation not defined.

这篇关于如何实现SQLite中的重音/音调符号不敏感的搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆