Chapter 1. Getting Started
Installing Ferret
First things first: let’s get Ferret installed. Thanks to RubyGems, this is pretty easy. If you haven’t used
RubyGems before, there is a great introduction at the RubyGems web site
(http://docs.rubygems.org/). If you
are on Windows and you used the Ruby One-Click Installer to install
Ruby, you’ll have everything you need. Other systems, such as Linux or Mac, need to have make
and a C compiler such as gcc to build the
extension. Other than that, Ferret comes dependency-free. You simply need to run the
gem install script:
dave$ sudo gem install ferret
Once this process successfully completes, you will have Ferret
installed on your system. The easiest way to check that everything is
working correctly is to open an irb session, as shown
in Example 1-1.
Example 1-1. irb session
dave$irb-rubygems>>require'ferret'#=> true>>index=Ferret::I.new#=> #<Ferret::Index:...>>>index<<"Time heals all wounds"#=> #<Ferret::Index:...>>>index<<"A rolling stone gathers no moss"#=> #<Ferret::Index:...>>>index<<"A stitch in time saves nine"#=> #<Ferret::Index:...>>>index<<"Look before you leap"#=> #<Ferret::Index:...>>>index<<"Time and tide wait for no man"#=> #<Ferret::Index:...>>>index<<"Time wounds all heels"#=> #<Ferret::Index:...>>>putsindex.search("time")
All we’ve done here is load RubyGems and Ferret, create a new in-memory index, add a few strings to it, and run a search, printing out the results. If everything is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access