Xapian in Python
para = '''this is a test'''And execute it again. Now we can search using a searcher: Save to file and execute it passing as a parameter the search term:
python search.py testYou will get both phrases but that one with "testing" will have lower probability. Xapian supports stemming for few languages. You set it with:
stemmer = xapian.Stem("english")Supported languages: none, danish (da), dutch (nl), english (en), finnish (fi), french (fr), german (de), italian (it), norwegian (no), portuguese (pt), russian (ru), spanish (es), swedish (sv).
For a Django news application with a model like this one: Indexing all news would look like this: Save it to a file in Django project folder, create "test" folder and execute (if you have such application ;) Diamanda news used here). To search you can use the same searcher as above. A example using news from my rkblog.rk.edu.pl website:
[piotr@localhost biblioteka]$ python simplesearch.py django Performing query `Xapian::Query(django)' 8 results found How to Beat Rails - 100% More crazy changes for Django 1.0 ? - 98% Big Django project ;) - 87% Django 0.96 released - 86% polib - gettext translation manager - 71% Diamanda 2006.12 Stable Released - 65% More on Django 1.0 changes - 65% Djangoish Gettext Translator - 57%
Pumping Up Your Applications with Xapian Full-Text Search - More advanced example using XML-RPC and Twisted