Full Text Search in Django

What is Full Text Search?

According to Wikipedia, In a full-text search, a search engine examines all of the words in every stored document as it tries to match search criteria.

Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

PostgreSQL has been supporting Full-Text Search since 2008. Internally it uses “tsvecor” and “tsquery” data type to process the data to search. It has some indexes that can be used to speed up the search: GIN and GiST. PostgreSQL added support for Phrase Search in 2016. Support for JSON[B] Full-Text Search was added in version 10.

Implementing Full Text Search in Django

We''ll be using PostgreSQL for our implementation.

Let's assume the following cases are valid for our implementation:

  • We have an Author model with name field
  • We have created instances as follows: 
    • Author.object.create(name='Timothy Olaleke')
    • Author.object.create(name='Mr Timothy Joseph')
    • Author.object.create(name='Dr. You Timothy')

Now Django allows us perform a full text search which returns a list of objects that matches the text been searched for.


This returns a list of instances with 'Timothy' , irrespective of where it appears within the name.

Feel free to explore our more sample from here.

Thanks for reading!


  1. All good. I am a newcomer, so I jerked until the money was withdrawn. I waited 2 days on Yandex. Thanks to the admins and support service for listening to my whining on the forum and in the chat. Play people! Do not be greedy. All the rules with this casino! perfectbest online slots I often spend my time here


Post a Comment

Popular Posts