Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

zapian is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
 
Links
Author
License
Private
Dependencies

作为一个pythoner,我们有理由爱xapian...

但xappy已年久失修过于陈旧了... 喜欢elasticsearch的api,但是憎恨Luence的java架构,不愿引入新的服务进程?

那么zapian,可能是你需要的....

欢迎拍砖: http://weibo.com/panjunyong

特性

  • 为xapian提供更友好的schemaless的api
  • 支持分区索引:可单独指定分区搜索,或合并搜索
    • 历史数据存放在不同的索引分区
    • 根据数据存放区域进行分区

Schemaless API

首先需要初始化数据库:

db = Zapian(path='/tmp/test_zapian_db')

添加一个分区:

db.add_part('2001-02')

添加索引:

db.add_document(part='2001-02',

uid='1111', index = { '+title' : u'我们很好.doc',

System Message: ERROR/3 (<string>, line 37)

Unexpected indentation.
'searchable_text' : u'', 'modified' : datetime.datetime(), 'crated' : datetime.datetime()

System Message: WARNING/2 (<string>, line 40)

Block quote ends without a blank line; unexpected unindent.

},

System Message: WARNING/2 (<string>, line 41)

Block quote ends without a blank line; unexpected unindent.

data = {}

System Message: WARNING/2 (<string>, line 42)

Block quote ends without a blank line; unexpected unindent.

)

修改索引:

db.replace_document(part, uid, doc)

删除索引:

db.delete_document(part, uid)

搜索:

db.search(parts, ["and",
{ "filters":
"exclude":

System Message: WARNING/2 (<string>, line 57)

Definition list ends without a blank line; unexpected unindent.

},

[ "or",
{"filters":
"exclude": },
{ "filters":
"exclude": }

System Message: WARNING/2 (<string>, line 64)

Definition list ends without a blank line; unexpected unindent.

]

System Message: WARNING/2 (<string>, line 65)

Block quote ends without a blank line; unexpected unindent.

]

System Message: WARNING/2 (<string>, line 66)

Block quote ends without a blank line; unexpected unindent.

)

doc和索引的关系

xapian内部对数据有三种用途:term索引、排序字段、返回data;系统自动对数据类型进行处理:

  • set/list/tuple:对每个包含数据,完整匹配搜索(term索引)
  • string/unicode: 用于全文搜索(term索引)
  • datetime/int/float: 用于排序和范围比较(排序字段)
  • 如果字符串类型的字段以 + 开头,表示除了全文索引,也会用于排序

数据库的结构

数据库存放在文件夹结构:

schema.yaml # 库结构信息 20120112/ # 某个分区,标准xapian数据库 20120512/ # 另外一个分区,标准xapian数据库

其中schema.json, 由系统自动维护, 记录了2个信息:

  1. PREFIX和字段的映射:

    prefixes:{title':"NC", 'created':"LL"}

  2. attribute存放的slot位置:

    slots:{'modified':1, 'created':2}

安装使用

  1. 需要先安装xapian:http://xapian.org/download
  2. 直接在pypi上安装这个包: https://pypi.python.org/pypi/zapian

Subscribe to package updates

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.