我有一个具有以下规范的用户模型:
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
项是sn
2的项。但是,当我在Searchkick :: Results对象上调用#map
方法时,它总是返回相同的顺序无论指定的顺序如何。
我有什么遗失的吗?
谢谢!