Created
November 15, 2012 09:28
-
-
Save bussyjd/4077626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'tire' | |
require 'yajl/json_gem' | |
require 'debugger' | |
#class Lastic | |
url = '' | |
content = '' | |
start = Time.now | |
def elasticpush(url,content) | |
puts content | |
#store :url => url, :content => content | |
end | |
Tire.index 'yahoo' do | |
delete | |
create | |
File.open('yahoo.txt', 'r').each_with_index do |line, i| | |
debugger if i == 64185 | |
if line =~ /^http/ | |
if content.length > 0 | |
puts "Problem id >> " + i.to_s | |
elasticpush(line,content) | |
end | |
#puts line | |
content = '' | |
line = '' | |
else | |
content += line | |
end | |
#break if i == 1000 | |
end | |
refresh | |
end | |
finish = Time.now | |
totaltime = finish - start | |
puts "Total time: #{totaltime}" | |
trap("INT") { supervisor.terminate; exit } | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment