With the proper permissions (that looks familiar to models.py, there we specify how we pick elements from the relational database to be searched, so with this file haystack knows what would be used to compare versus the searched thing, in other words, with this file the index is generated, so when someone searches, the document database is hit, but not your relational database. Where rt is your project, you have a search_sites.py file inside it, more on this later, and you have the directory HAYSTACK_XAPIAN_PATH = '/var/lib/rtsearch/rtindex' If you are wondering what does requirements.txt is about, take a look at virtualenvĪnd configure the following variables in your settings.py, make sure you have this variables defined BEFORE the apps configuration: Django with haystackĬomplement your requirements.txt with the following lines.
We assume you have python 2.7, if not, the copy/paste technique won't work directly.Īssuming your virtualenv is called tr, the following script should work tweaking your vars according to your installation We assume you are working with a virtualenv, if you are not already using it, go for it first :), if you are using Debian or Ubuntu, you can follow this guide straightforward, other flavors or oses should work, but you will need to work on it by yourself or upgrade to the recommended Oses we use here. Wait, you have already a relational database, now you are adding a document database, so in your next geek party you would be able to speak fluently about it note that you will have a second database specialized for searches, so the process is like this : you add or update a record to your original database, the system adds or updates a record to the document database, the "index" can be updated and the searches go only in the document database letting your relational database do the things it has to do in your deploy and not overwhelming it with the user search requests.
If you have plenty of hardware go for solr, if you don't expect so many visits go for whoosh, but for sure you will find xapian really cool.
When you have a Django site and you don't want to torture your database with searches, but you want to offer your users the possibility of having a nice search tool, you could take a look at haystack, this is a configurable search engine where you can pick backends such as xapian, solr and whoosh, among others.