D
David Balmain
------=_Part_8617_31987395.1129862171462
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi Folks,
I know there have been at least a few people looking for something like thi=
s
on the mailing list, so please check it out. It's a port of a Java project
so I'd particularly like to hear how I can make it more Ruby like. Enjoy!
Dave Balmain
=3D=3D Description
Ferret is a full port of the Java Lucene searching and indexing library.
It's available as a gem so try it out! To get started quickly read the quic=
k
start at the project homepage;
http://ferret.davebalmain.com/trac/
=3D=3D Quick (Very Simple) Example
require 'ferret'
include Ferret
docs =3D [
{ :title =3D> "The Pragmatic Programmer",
:author =3D> "Dave Thomas, Andy Hunt",
:tags =3D> "Programming, Broken Windows, Boiled Frogs",
ublished =3D> "1999-10-13",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Programming Ruby",
:author =3D> "Dave Thomas, Chad Fowler, Andy Hunt",
:tags =3D> "Ruby",
ublished =3D> "2004-10-06",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Agile Web Development with Rails",
:author =3D> "Dave Thomas, David Heinemeier Hansson, Leon Breedt, Mike Clar=
k,
Thomas Fuchs, Andreas Schwarz",
:tags =3D> "Ruby, Rails, Web Development",
ublished =3D> "2005-07-13",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Ruby, Developer's Guide",
:author =3D> "Robert Feldt, Lyle Johnson, Michael Neumann",
:tags =3D> "Ruby, Racc, GUI, FOX",
ublished =3D> "2002-10-06",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Lucene In Action",
:author =3D> "Otis Gospodnetic, Erik Hatcher",
:tags =3D> "Lucene, Java, Search, Indexing",
ublished =3D> "2004-12-01",
:content =3D> "Yada yada yada ..."
}
]
index =3D Index::Index.new()
docs.each {|doc| index << doc }
puts index.size
puts "\nFind all documents on ruby:-"
index.search_each("tags:Ruby") do |doc, score|
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
puts "\nFind all documents on ruby published this year:-"
index.search_each("tags:ruby AND published: >=3D 2005") do |doc, score|
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
puts "\nFind all documents by the Pragmatic Programmers:-"
index.search_each('author
"dave Thomas" AND "Andy hunt")') do |doc, score|
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
------=_Part_8617_31987395.1129862171462--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi Folks,
I know there have been at least a few people looking for something like thi=
s
on the mailing list, so please check it out. It's a port of a Java project
so I'd particularly like to hear how I can make it more Ruby like. Enjoy!
Dave Balmain
=3D=3D Description
Ferret is a full port of the Java Lucene searching and indexing library.
It's available as a gem so try it out! To get started quickly read the quic=
k
start at the project homepage;
http://ferret.davebalmain.com/trac/
=3D=3D Quick (Very Simple) Example
require 'ferret'
include Ferret
docs =3D [
{ :title =3D> "The Pragmatic Programmer",
:author =3D> "Dave Thomas, Andy Hunt",
:tags =3D> "Programming, Broken Windows, Boiled Frogs",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Programming Ruby",
:author =3D> "Dave Thomas, Chad Fowler, Andy Hunt",
:tags =3D> "Ruby",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Agile Web Development with Rails",
:author =3D> "Dave Thomas, David Heinemeier Hansson, Leon Breedt, Mike Clar=
k,
Thomas Fuchs, Andreas Schwarz",
:tags =3D> "Ruby, Rails, Web Development",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Ruby, Developer's Guide",
:author =3D> "Robert Feldt, Lyle Johnson, Michael Neumann",
:tags =3D> "Ruby, Racc, GUI, FOX",
:content =3D> "Yada yada yada ..."
},
{ :title =3D> "Lucene In Action",
:author =3D> "Otis Gospodnetic, Erik Hatcher",
:tags =3D> "Lucene, Java, Search, Indexing",
:content =3D> "Yada yada yada ..."
}
]
index =3D Index::Index.new()
docs.each {|doc| index << doc }
puts index.size
puts "\nFind all documents on ruby:-"
index.search_each("tags:Ruby") do |doc, score|
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
puts "\nFind all documents on ruby published this year:-"
index.search_each("tags:ruby AND published: >=3D 2005") do |doc, score|
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
puts "\nFind all documents by the Pragmatic Programmers:-"
index.search_each('author
puts "Document <#{index[doc]["title"]}> found with a score of %0.2f" % scor=
e
end
------=_Part_8617_31987395.1129862171462--