Al-Alamin
Al-Alamin

Reputation: 1468

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 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)

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?

Upvotes: 2

Views: 741

Answers (1)

Al-Alamin
Al-Alamin

Reputation: 1468

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.

Upvotes: 4

Related Questions