Django Postgres pg_trgm模块,带有用于全文搜索的djormextpgfulltext

2024-04-29 14:01:41 发布

您现在位置:Python中文网/ 问答频道 /正文

在django1.6和postgres以及模块djorm-ext-pgfulltext中,我尝试使用贪婪匹配(即:app将匹配apple)而不是精确的单词匹配来执行全文搜索。在

我看到postgres有pg\utrgm模块(http://www.postgresql.org/docs/9.0/static/pgtrgm.html)来实现这一点(匹配搜索词的3个连续字符)。然而,我对如何在djorm-ext-pgfulltext中集成/使用它感到困惑。我知道SearchManager()确实需要配置参数,但我不确定我将如何在其中使用pg\u trgm。我仔细阅读了如何制作我自己的配置文件enter link description here,但我看不出在那里集成pg_trgm的方法。在

objects = SearchManager(
    fields = ('name', 'description'),
    config = 'pg_catalog.english', # this is default
    search_field = 'search_index', # this is default
    auto_update_search_field = True
)

Tags: 模块appdefaultfieldsearchispostgresdescription