Full text search with Django and PostgreSQL
Published on 2022-06-07
Django applications that use PostgreSQL as database can utilize its
full text search capabilities.
The following issues and educational pull requests gradually introduce new
features. Look at the changed files to learn what was needed to implement it.
To set up the project, follow the instructions in the
- #1 Add naive search based on SQL-Like
- Allows to search for single words very slowly using SQL “like” operator
- No pull request, code can be found in main branch
- #2 Add advanced search queries
- Allow search queries with boolean operators, phrases and prefix-search
- Changed files in #8
- #3 Add ranking
- Sort search results by rank
- Changed files in #9
- #4 Add search index
- Improve performance of search by indexing
- Changed files in #10
- #5 Add weights
- Weight findings differently depending on the field it is found in (for example, title vs body text)
- Changed files in #11
- #6 Improve rank of long documents
- Long documents containing the search team multiple times have a lower rank than shorter documents with the same number of occurrences.
- Changed files in #13
- #7 Add search headlines for text and title
- On the search result page, the searcher can see search headline of both the title and text.
- Changed files in #14
- #12 Add language support
- Use stopwords and stemming depending on language of the text
- Changed files in #15