al alamin al alamin - 7 months ago 68
SQL Question

django 1.10 postgres full text search is not working

I am trying to integrate full text search for django 1.10 with postgres database.
I am following tutorial from

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

I have several questions in the database which has the text 'for' in its text field for example: one question is:

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

I am trying to make a query like

q = Question.objects.filter(text__search='for')

But this query is not returning any result. can anyone suggest me why?


It is actually my mistake. For Full text search when Postgres creates index it by default ignore common words like 'the', 'for', 'are','is' etc. So If you try to search using this keywords you search query will return empty even if there are lots of sentences with these words. I did not know this. So I thought I misconfigured.