Django PostgreSQL搜索返回的结果少于预期的结果

时间:2019-03-07 05:39:33

标签: django postgresql

说我有以下queryset的胡萝卜:

<QuerySet [
    <Carrot: Blue carrot>, 
    <Carrot: Purple carrot>, 
    <Carrot: Apple carrot>, 
    <Carrot: Yellow Carrot>, 
    <Carrot: Green carrot>
]>

我可以使用以下方法过滤<Carrot: Apple carrot>

queryset.filter(name__icontains="app")

但是,如果我使用PostgreSQL's search lookup尝试相同的过滤器:

queryset.filter(name__search="app")

我得到一个空的查询集。为什么是这样?我希望PostgreSQL的搜索查找将返回部分单词匹配的结果。

是否有一种方法可以放宽__search的约束,以便我可以将该功能用作预输入搜索字段的后端?

0 个答案:

没有答案