在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
)
找到了这个解决了我所有问题的帖子。我只需要进入数据库并运行
CREATE EXTENSION pg_trgm;
Similarity function in Postgres with pg_trgm
相关问题 更多 >
编程相关推荐