[Answered ]-Search app in Django

2👍

As far as i can tell, there are two ways of going about this.

Firstly, there are sort modes SPH_SORT_RELEVANCE, SPH_SORT_ATTR_DESC, SPH_SORT_ATTR_ASC, SPH_SORT_TIME_SEGMENTS, SPH_SORT_EXTENDED. I assume that keyword in the SphinxSearch constructor would be sortmode, but I couldn’t find the docs.

search     = SphinxSearch(
                index    = 'trial_data trial_datastemmed',
                weights  = {'name': 100,},
                mode     = 'SPH_MATCH_ALL',
                rankmode = 'SPH_RANK_BM25',
                sortmode = 'SPH_SORT_RELEVANCE', # this was added
                )

Secondly, you can specify at time of query the sort mode:

res = trial_data.search.query('godfather').order_by('@relevance')

Both of these answers are guesses from looking at http://djangosnippets.org/snippets/231/. Let us know if it worked for you.

Leave a comment