我有两个模型:'A‘和'B',并且希望使用思考的斯芬克斯从它们中搜索对象,但是我想要模型'A’的所有结果,然后'B‘。我怎么能这么做?我将下列选项传递给sphinx查询
{:match_mode=>:extended, :sort_mode=>:extended, :star=>true, :order=>"@relevance DESC", :ignore_errors=>true, :populate=>true, :per_page=>10, :retry_stale=>true, :classes => [A,B]}然后使用以下方法获取搜索结果:
ThinkingSphinx.search "*xy*", options但是它给出了混合排序的结果,而我首先需要所有'A‘对象。我怎么能这么做?
发布于 2014-02-12 11:54:54
最简单的方法是向两个模型的索引中添加一个属性:
has "1", :as => :sort_order, :type => :integer每个模型中的字符串中的数字应该不同。然后您的:order参数变成:
:order => 'sort_order ASC, @relevance DESC'https://stackoverflow.com/questions/21725463
复制相似问题