django 1.10 postgres 全文搜索不工作

django 1.10 postgres full text search is not working

我正在尝试将 django 1.10 的全文搜索与 postgres 数据库集成。 我正在关注来自 https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/search/

class Question(models.Model):
    text = models.TextField(max_length=500)
    ans = models.TextField(max_length=1500, blank=True)

我在数据库中有几个问题,例如在其文本字段中有文本 'for':一个问题是:

text: what is best for me?
ans: this is best for you.

我正在尝试进行类似

的查询
q = Question.objects.filter(text__search='for')

但是这个查询没有返回任何结果。谁能告诉我为什么?

其实是我的失误。对于全文搜索,当 Postgres 创建索引时,默认情况下会忽略 'the'、'for'、'are'、'is' 等常用词。因此,如果您尝试使用此关键字进行搜索,您即使有很多句子包含这些词,搜索查询也会 return 为空。 我不知道这个。所以我以为我配置错误。