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
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