Revision: 6093
Updated Code
at April 27, 2008 08:34 by narkisr
Updated Code
require 'rubygems'
require 'ferret'
require 'find'
wot = ARGV[0]
if wot.nil?
puts "use: search.rb <query>"
exit
end
index = Ferret::Index::Index.new(:default_field => 'content', :path => '/tmp/index_folder')
ini = Time.now
puts "Searching.."
docs=0
index.search_each(wot, options={:limit=>:all}) do |doc, score|
res= <<STRING_END
-------------------------------------------------------
#{File.basename(index[doc]['file'])} :
#{index.highlight(wot, doc,:field => :content,:pre_tag => "->>",:post_tag => "<<-")}
STRING_END
puts res
docs+=1
end
elapsed = Time.now - ini
puts "Elapsed time: #{elapsed} secs\n"
puts "Documents found: #{docs}"
Revision: 6092
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 27, 2008 07:25 by narkisr
Initial Code
require 'rubygems'
require 'ferret'
require 'find'
wot = ARGV[0]
if wot.nil?
puts "use: search.rb <query>"
exit
end
index = Ferret::Index::Index.new(:default_field => 'content', :path => '/tmp/index_folder')
ini = Time.now
puts "Searching.."
docs=0
index.search_each(wot, options={:limit=>:all}) do |doc, score|
res= <<STRING_END
-------------------------------------------------------
#{File.new(index[doc]['file']).base_name} :
#{index.highlight(wot, doc,:field => :content,:pre_tag => "->>",:post_tag => "<<-")}
STRING_END
puts res
docs+=1
end
elapsed = Time.now - ini
puts "Elapsed time: #{elapsed} secs\n"
puts "Documents found: #{docs}"
Initial URL
Initial Description
This is an example of how to search within a Ferret index (based upon http://kasparov.skife.org/blog/src/ruby/ferret.html).
Initial Title
Ruby Ferret Simple Indexing And Search Example Part 2
Initial Tags
search, ruby
Initial Language
Ruby