Thinking Sphinx- order by year and relevance
我正在使用ThinkingSphinx作为网页上的搜索引擎。我需要的是按年份和相关性对搜索结果进行排序。
由于
在带有Sphinx 2.1.6的OSX上使用Think Sphinx V2的工作代码
1 | :sphinx_select =>"*, YEAR(created_at) as created_at_year", :order =>"created_at_year DESC, weight() DESC") |
在带有Sphinx 2.0.6的BSD上思考Sphinx V2的代码
1 | :sphinx_select =>"*, YEAR(created_at) as created_at_year, weight() as my_weight", :order =>"created_at_year DESC, my_weight DESC") # can't be aliased as weight! |
这假定您正在使用TS v3:
1 2 3 | Model.search 'foo', :select => '*, YEAR(created_at) as created_at_year, weight() as weight', :order => 'created_at_year DESC, weight DESC' |