1

我有一个具有以下规格的用户模型:

def search_data
    {
        full_name: full_name,
        published: published,
        sn: sn
    } 
end

然后我尝试在sn现场获得有序的结果。这是我的查询:

User.search("pablo", order: {sn: :asc}, fields: [:full_name], limit: 10)

检查生成的对象会发现它正在按预期工作:

User.search("pablo", order: {sn: :asc}, fields: [:full_name], limit: 10)给出:

#<Searchkick::Results:0x007feae41a3958
 @klass=User,
 @options={:page=>1, :per_page=>10, :padding=>0, :load=>true, :includes=>nil, :json=>false},
 @response=
  {"took"=>75,
   "timed_out"=>false,
   "_shards"=>{"total"=>1, "successful"=>1, "failed"=>0},
   "hits"=>
    {"total"=>5,
     "max_score"=>nil,
     "hits"=>
      [{"_index"=>"users_production_20150409165753551", "_type"=>"user", "_id"=>"551598ba32663300160d0000", "_score"=>nil, "sort"=>[1]},
       {"_index"=>"users_production_20150409165753551", "_type"=>"user", "_id"=>"54e3ba1d6538630003090000", "_score"=>nil, "sort"=>[2]}]}}>

你可以看到第一个项目hits是应该的。如果我运行指定降序的查询,那么第一hits项是带有sn2 的那个。但是,当我#map在 Searchkick::Results 对象上调用方法时,它总是返回相同的顺序,而与指定的顺序无关。

有什么我想念的吗?

谢谢!

4

0 回答 0