django 1.7的postgresql全文检索实现

django-pg-fts的Python项目详细描述


====
django pg fts
====



django 1.7全文搜索的实现postgesql,利用新功能迁移和自定义查找。



功能:

-fieldlookup的搜索、iSearch、tsquery

-支持标准化排名,使用注释

-迁移类帮助创建和删除索引,支持"gin"或"gist"

-迁移类以帮助创建和删除触发器

-多个字典支持触发器和字段查找

-支持python 2.7、3.3和3.4




支持多个字典,索引和触发器迁移

=models.textfield()

并赋予"a"的标题权重。


import tsvectorfield::


from pg fts.fields import tsvectorfield

add to existing tsvectorfield to model and tell the fields that you want to index and the dictionary:

fts=tsvectorfield(字段=("title","a"),"article"),dictionary='english')


create migrations文件::



从pg_fts.migrations导入(createftsindexoperation、createftstriggeroperation,
updatevectoroperation)


并添加到操作结尾::


为已存在的数据更新向量
updatevectoroperation(
name="article",
field='fts',
),
为自动插入和更新向量创建触发器
createftsTriggerOperation(
name='article',
field='fts'

为向量创建gin索引
createftsindexoperation(
name='article',
field='fts',
index='gin'



对数据库进行更改::


字段和更新向量字段。

代码块::sql

tsvector@@to_tsquery('english','waz&;up')


>或iSearch将匹配一些单词:

>;>;article.objects.filter(fts_u isearch='waz up')


将生成类似于:

代码块::sql

tsvector@@to_tsquery('english','waz up')


,但您可以生成原始的tsquery:

>;>;article.objects.filter(fts_u tsquery='waz&;!up')

将导致类似于:

…代码块::sql

tsvector@@到tsquery('engli嘘,'哇!up')

,并按规范化和顺序对结果进行排序:

>pg fts.randes import fts rank
>>article.objects.filter(
rank=ftsrank(fts_search='waz up',normalization=[1,3])。按('-rank')

`.

文档
----


从github克隆::

git clone git://github.com/dvdmgl/django-pg-fts.git django pg fts


您应该运行测试::

python run tests.py


tox


使用github中的pip安装:



或使用setup.py:

python setup.py

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javascript生成两点之间的固定纬度和经度   java为什么不删除并重命名文件?   求数组的和   java在漂亮面孔中使用正则表达式   SOAP(java)中的Hello World。如何修复它?   java I获取应用程序生成错误,配置为“”的资源“attr/arc_position”的值重复   云基础环境中的Java SFTP客户端应用   谷歌应用程序引擎Java查询日期不正常?   java使用cancel按钮对JOptionPane InputDialog循环进行转义   java数字格式总是返回异常   xquery Java Saxon API以“追加”模式写入文件   java Azure函数在第二个插槽中没有响应   java在构建Play应用程序后向其添加动态依赖项   json如何使用Jackson mapper for java。木卫一。可序列化类型字段?