对于PostgreSQL中的小型搜索,http://django-orm.readthedocs.org/en/latest/orm-pg-fulltext.html可以很容易地使用,如文档中所示。在
以下是我用来实现它的步骤-
'''call the libraries'''
from djorm_pgfulltext.models import SearchManager
from djorm_pgfulltext.fields import VectorField
class Notes(models.Model):
title = models.CharField()
description = models.TextField()
# create a vector field
search_index = VectorField()
objects = models.Manager()
search_manager = SearchManager(
fields=('title', 'description'),
config='pg_catalog.english',
search_field='search_index',
auto_update_search_field=True
)
运行了迁移,所有更改都反映在数据库中。 最后一步- 在我的postgresql数据库中,我执行了以下操作-
^{pr2}$所有这些都完成了,现在我打开我的外壳
from myapp.models import Notes
In [2]: Note.search_manager.search("p")
Out[3]: []
你知道为什么我没有结果吗??在
少了什么?在
目前没有回答
相关问题 更多 >
编程相关推荐