It seems I suck at documentation (yes, It’s very true), so here’s a quick How-to on using the Sphinx ORM for Django we created:
- Download and install Sphinx (you’re on your own here): http://www.sphinxsearch.com/
- Download and install the Django Sphinx package: http://django-sphinx.googlecode.com/ (again, on your own)
- Setup a source for your table:
source files_file_en : base { sql_query = \ SELECT files_file.id, files_file.name, files_data.description, files_file.tags as tag \ FROM files_file JOIN files_data \ ON files_file.id = files_data.file_id \ AND files_data.lang = 'en' \ AND files_file.visible = 1 \ GROUP BY files_file.id sql_query_info = SELECT * FROM files_file WHERE id=$id } - Setup an index for your table:
index files_file_en { source = files_file_en path = /var/data/files_file_en docinfo = extern morphology = none stopwords = min_word_len = 2 charset_type = sbcs min_prefix_len = 0 min_infix_len = 0 } - Go into your models and add the import:
from cursesite.core.search.models import SphinxSearch
- Go to the model you want to attach the search to:
search = SphinxSearch(index="files_file_en")
- Now query:
File.search.query('hello')
