Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails SearchKick获取总结果计数_Ruby On Rails_Searchkick - Fatal编程技术网

Ruby on rails SearchKick获取总结果计数

Ruby on rails SearchKick获取总结果计数,ruby-on-rails,searchkick,Ruby On Rails,Searchkick,我正在使用SearchKick搜索数据。我正在进行分页。在这种情况下,如何获取总结果计数: 我的searchkick结果: #<Searchkick::Results:0x007faeeef8ed88 @facets=nil, @max_score=0.0, @options= {:load=>true, :payload=> {:query=>{:match_all=>{}}, :size

我正在使用
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>,...]....
它返回给我的错误是:


undefined method
response'`

Searchkick提供了一种计算响应总点击次数的
#total_count
方法:

在searchkick(0.9.0)中,它是:
响应。总计数

SearchKickResult.response
def total_count
  response["hits"]["total"]
end
alias_method :total_entries, :total_count