Search refinements

Feb 13th 2008

I spent a couple of hours this morning refining the search function to make its behaviour a little more intelligent when dealing with lists of words, and to allow exclusion of terms using a - sign in front of the term, a bit like Google does.

Lists of words can be entered with a 'space' character between them, and Surftrackr will handle this slightly more intelligently. Previously, the space would have been URL-quoted (because spaces are illegal in URLs) and the whole string searched for in all URLs in the database.

Previous behaviour: enter a string like 'hello world' and 'hello%20world' would be searched for.

New behaviour: enter 'hello world' and it will be split into individual words, and web addresses containing all words (in any position in the URL) will be returned. As a bonus, a phrase like 'hello -world' would match 'hello' but exclude 'world'.

New source code available at the download site. If you don't want to go through the shenanigans of a re-install, just unpack the download file and copy these files into your Surftrackr installation:

search/views.py
templates/search/search.html

Do a ./manage syncdb and restart your Apache so the changes take effect.