Tokyo Dystopia 全文搜索

本文介绍了一个名为TokyoDystopia的数据库模块的使用方法,重点在于其提供的复合表达式搜索功能。该功能允许用户通过多种组合方式精确查找记录,例如使用逻辑运算符进行复杂查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[url]http://d.hatena.ne.jp/perezvon/20080921/1222016246[/url]


>>> from tokyodystopia import TokyoDystopia
>>> db = TokyoDystopia("/tmp/test.db", 255)
>>> db.put(0, u"仙台".encode("utf8"), " ")
1
>>> db.put(1, u"仙台 広島".encode("utf8"), " ")
1
>>> db.put(2, u"広島 山形 湘南 山形".encode("utf8"), " ")
1
>>> db.search(u"仙台".encode("utf-8"))
2
[0L, 1L]
>>> db.search(u"広島".encode("utf-8"))
2
[1L, 2L]
>> db.close()


The function `tcidbsearch2' searches with a compound expression. In the compound expression, tokens are separated by one or more white space characters. If one token is specified, records including the specified pattern are searched for. Upper or lower case is not distinguished. Accent marks and diacritical marks are ignored. If two or more tokens are specified, records including all of the patterns are searched for. The compound expression includes the following sub expressions.

* A B : searches for records including the two tokens.
* A && B : searches for records including the two tokens.
* A || B : searches for records including the one or both of the two tokens.
* "A B..." : searches for records including the phrase.
* [A] : searches for records including words exactly matching the token.
* [A*] : searches for records including words beginning with the token.
* [*A] : searches for records including words ending with the token.
* [[A : searches for records beginning with the token.
* A]] : searches for records ending with the token.

Note that the priority of "||" is higher than the one of "&&".
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值