Android中的SQLite全文搜索unicode [英] SQLite full-text search unicode in android

查看:187
本文介绍了Android中的SQLite全文搜索unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  CREATE VIRTUAL TABLE Demo1 USING fts3(content TEXT ); 

插入Demo1值('HồThanh Long'),('NguyễnVănA')

搜索时:

  select * from Demo1其中内容匹配'H''

然后结果是:

  'HồThanh Long'

搜索时:

< pre $ select * from Demo1 where match'Ho'

然后没有结果。



帮助我!

解决方案

简单的tokenizer支持unicode:


其中符合条件的字符全部是字母数字字符,并且Unicode码值大于
的所有字符或者等于128.


它只是没有做任何事情。我不确定即使Unicode标记器也会执行你需要的映射。 (即在查询时将'H''识别为'H''和'Ho')。

确实,演示在您查询时会识别'H';当你询问'Ho'时,它没有返回它,因为它没有将它们识别为等价物。如果您使用的是受限制的Unicode字符集,则可以实现自己的映射,并将纯ASCII文本保存在单独的列中以分别进行搜索。

I am creating a table in SQLite using fts(3 or 4)

CREATE VIRTUAL TABLE Demo1 USING fts3(content TEXT);

insert into Demo1 values('Hồ Thanh Long'),('Nguyễn Văn A')

When search:

select * from Demo1 where content  Match 'Hồ' 

Then result is:

'Hồ Thanh Long'

When search:

select * from Demo1 where content  Match 'Ho' 

Then no result.

Help me!

解决方案

The default "simple" tokenizer for android supports unicode:

where eligible characters are all alphanumeric characters and all characters with Unicode codepoint values greater than or equal to 128.

It just doesn't do anything else. I'm not sure even the Unicode tokenizers would do the mapping you require. (i.e. recognize 'Hồ' as both 'Hồ' and 'Ho' when queried.)

Indeed, the demo recognized 'Hồ' when you queried it; it just didn't return it when you queried 'Ho' because it didn't recognize them as equivalents. If you are working with a limited set of supported Unicode characters, you could implement your own mapping, and save the "plain ASCII text" in a separate column to search on separately.

这篇关于Android中的SQLite全文搜索unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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