This post originated from an RSS feed registered with Java Buzz
by Brian McCallister.
Original Post: Ferret!
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
David Balmain has released Ferret unto the
world. Ferret is one of the most requested libraries I have seen for
ruby -- a native port (not a gcj and bindings!) of Lucene!
#!/usr/bin/env ruby
require 'rubygems'
require 'ferret'
require 'find'
include Ferret
# index = Index::Index.new(:path => '/tmp/ferret-test')
index = Index::Index.new(:default_field => 'content')
Find.find("/Users/brianm/blosxom/entries/src/") do |path|
if FileTest.file? path
File.open(path) do |file|
index << {:file => path,
:content => file.readlines.join }
end
end
end
index.search_each("Lucene") do |doc, score|
puts index[doc]['file']
end