2015-04-28 116 views
2

我正在使用SearchKick来搜索数据。我正在执行分页。我怎样才能得到总的结果数在这种情况下:SearchKick获得总结果数

我searchkick结果:

 #<Searchkick::Results:0x007faeeef8ed88 
    @facets=nil, 
    @max_score=0.0, 
    @options= 
    {:load=>true, 
    :payload=> 
     {:query=>{:match_all=>{}}, 
     :size=>20, 
     :from=>0, 
     :sort=>{"created_at"=>:desc}, 
     :filter=>{:and=>[{:term=>{"sub_category_id"=>2}}]}, 
     :fields=>[]}, 
    :size=>20, 
    :from=>0, 
    :term=>"*"}, 
    @response= 
    {"took"=>4, 
    "timed_out"=>false, 
    "_shards"=>{"total"=>5, "successful"=>5, "failed"=>0}, 
    "hits"=> 
     {"total"=>1925, 
     "max_score"=>nil, 
     "hits"=> 
     [{"_index"=>"products_..", "_type"=>"product", "_id"=>"..", "_score"=>nil, "sort"=>[..]},....]}}, 
    @results= 
    [#<Product>,...].... 

还有一两件事我不能够做到:

SearchKickResult.response 

它返回我的错误说:

undefined method response'`

回答

1

在searchkick(0.9.0),它是: response.total_count