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.
- [Answered ]-Django: provide month and year number as parameter in a template for use in template tag
Source:stackexchange.com