puts "query_body:#{es_query_body}" first = query_es((es_query_body), "15m", index_name) es_res = JSON.parse(first) scroll_id = es_res["_scroll_id"] (puts "error:#{first} "andreturn ) if es_res.nil?
es_res["hits"]["hits"].each do |item| puts "new item:" puts item endunless es_res["hits"].nil?
0.upto 1000do |i| es_res_body = scroll("15m",scroll_id) es_res_obj = JSON.parse(es_res_body) unless es_res_obj.has_key? "hits" puts "index_name #{index_name} has no hits" puts es_res_body return end if es_res_obj["hits"]["hits"].size==0 puts "index #{index_name} cost #{Time.new.to_f - t1} seconds" return end es_res_obj["hits"]["hits"].each do |item| save item end end end
defquery_body_of_from_id(from_id,query_size=100) definition = search do query do bool do must do match from_id:from_id end end size query_size end end definition.to_hash end