Posted 7:01 p.m., Wednesday 28 January, 2009.
Recently, I have wanted to improve the searching ability in a number of my Django projects. I've often added a search box that simply does an
icontains filter, which works fine for small sites but doesn't scale due to the inefficiency of matching text with basic SQL queries. The plus side of an
icontains filter is that it works on all of Django's database backends (with the exception of SQLite, which works but in a case-sensitive way), so it can be useful for pluggable applications to implement. I wanted something that could do some heavier lifting, so I looked into
tsearch2 - a PostgreSQL plugin that provides full-text indexing and searching that's twice as fast as standard
icontains filters. On DjangoSites I managed to reduce my search queries to half their original time, with improved accuracy. Read the full article to find out how.
Want to see more? Check out the yearly archives below.
© Copyright 2006- Ross Poulton. All Rights Reserved unless explicitly defined.
Opinions expressed here are my own, and not those of my employer or any other party.