3

Full text search with mysql & django can be done using following django api query

Entry.objects.filter(headline__search="search text")

This returns result set properly.But this can't be used with postgresql, while using getting an exception which is shown below

Full-text search is not implemented for this database backend 

How can i imlement full text search with postgresql & django which is same as that of django-mysql full text search?

3 Answers 3

4

You can try

Entry.objects.filter(headline__contains="search text")

or __icontains for case-insensitive search.

As the django doc says __search only works with MySQL for now.

Sign up to request clarification or add additional context in comments.

3 Comments

@ Rohan,This query returns the result set which having exact match, Is there any option for including partial match also?
@Jafarali, I don't think __contains does exact match (ref : docs.djangoproject.com/en/dev/ref/models/querysets/#contains), for exact match you need to use __exact. However, it would check for both (all) words given to look for.
@ Rohan,Suppose checking for a match against the record "welcome to the new world" with query __contains="welcome world" , returns zero records.
2

You may try Haystack or user-created library djorm-ext-pgfulltext. Also it is useful to read https://code.djangoproject.com/ticket/4676 and http://bogdan-ivanov.com/entry/full-text-search-postgresql-and-django/

Comments

0

For user reading this question these days:

PostgreSQL Full-Text-Search support is present since Django 1.10 (2016) by the module django.contrib.postgres.search .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.