First shot on full-text search
Ref: #12 (closed), #38 (closed)
Still following the "make it simple for now, avoid as much as possible dependencies" mantra, I've implemented a quick full text search using the FTS functionality of SQLite.
Basically, we create some special virtual table at post migrate, and we have a dedicated model that will index data on it.
Then any model that we want searchable should inherit from a SearchableMixin
that will give this model the needed methods (index
and deindex
for example), and also make that the instance will be indexed at post save and deindexed at post delete.
A QuerySet mixin is also provided to add a search
method.
It's all very simple and djangoic; the only tricky part is the ranking: the SQLite FST doesn't provide any rank function to score the result by relevancy, so we needed to code our.
Also a fist version of a search box and search page has been added.