Microsoft's Internet Explorer browser has no built-in vector graphics machinery required for "loss-free" gradient background themes.

Please upgrade to a better browser such as Firefox, Opera, Chrome, Safari or others with built-in vector graphics machinery and much more. (Learn more or post questions or comments at the Slide Show (S9) project site. Thanks!)

Ferret Full Text Indexing

Example (look ma, no rails!)

   1  require 'ferret'
   2  include Ferret
   3  i = Index::Index.new
   4  i << "Time heals all wounds"
   5  i << "A rolling stone gathers no moss"
   6  i << "A stitch in time saves nine"
   7  i << "Look before you leap"
   8  i << "Time and tide wait for no man"
   9  i << "Time wounds all heels"
  10  
  11  i.search("time")
  12  #<struct Ferret::Search::TopDocs total_hits=4

Ferret Documents

Documents

   1  
   2  i << { :lyric => "Someone flopped a steamer in the gene pool",
   3         :by => "NOFX", :song => "Idiots are Taking Over" }          
   4  
   5  i << { :lyric => "When she crossed those big white thighs",
   6         :by => "Hefner", :song => "Hymn for the Coffee" }
   7  
   8  i << { :lyric => "Let marrow bone and cleaver choose",
   9         :by => "Tom Waits", :song => "Singapore" }

Ferret Document Class

   1  
   2  doc = Document.new(2) # Boost of 2
   3  doc[:lyric] = "We're lizards wrapped in warm fat"
   4  doc[:by] = "The Gillroyd Parade"
   5  doc[:song] = "We Are Fish"
   6  i << doc

Ferret Query Language

   1  
   2  i << { :lyric => "Someone flopped a steamer in the gene pool",
   3         :by => "NOFX", :song => "Idiots are Taking Over" }          
   4  i << { :lyric => "When she crossed those big white thighs",
   5         :by => "Hefner", :song => "Hymn for the Coffee" }
   6  i << { :lyric => "Let marrow bone and cleaver choose",
   7         :by => "Tom Waits", :song => "Singapore" }
   8  
   9  i.search("lyric:(steamer OR cleaver)")
  10  i.search("lyric:(gene AND pool)")
  11  i.search("*oo*")
  12  i.search("waites~")
  13  i.search("song:'hymn for the coffee' lyric:thighs")
  14  i.search("lyric:'let <> bone'")
  15  i.search("* -steamer")

Building Queries With Objects

   1  
   2  query = MultiTermQuery.new(:lyric)
   3  query.add_term("steamer")
   4  query.add_term("cleaver")
   5  
   6  query = FuzzyQuery.new(:by, "waites")

Scoring

Example: A file indexer

Defining The Fields

   1  
   2  i = Index::Index.new(:path => "/tmp/filesearcher")
   3  
   4  i.field_infos.add_field(:file_name, :store => :yes)
   5  
   6  i.field_infos.add_field(:file_size, :store => :no,
   7                          :index => :untokenized)
   8  
   9  i.field_infos.add_field(:content, :store => :no)

Find and Index the files

   1  
   2  Dir.glob("sphinx.git/**/*") do |file_name|
   3    next unless File.file?(file_name)
   4    text = File.open(file_name) { |f| f.read(10 * 1024) }
   5    i << { :file_name => file_name, 
   6           :file_size => File.size(file_name),
   7           :content => text }
   8  end

Search Interface

   1  
   2  i.search_each("sphinx") do |id, score|
   3    doc = i[id]
   4    puts "%1.5f: %s" % [score, doc[:file_name]]
   5  end

0.04892: /home/john/devel/sphinx.git/sphinx.spec
0.02157: /home/john/devel/sphinx.git/sphinx-min.conf.in
0.01233: /home/john/devel/sphinx.git/configure.ac
0.01079: /home/john/devel/sphinx.git/configure
0.00616: /home/john/devel/sphinx.git/sphinx.conf.in
0.00616: /home/john/devel/sphinx.git/sphinx.conf.in

Explain

   1  
   2  i.explain("sphinx", 2)
   3  => 0.006163515 = product of:
   4    0.01849055 = weight(content:sphinx in 2), product of:
   5      0.3239199 = query_weight(content:sphinx), product of:
   6        1.826679 = idf(doc_freq=6)
   7        0.1773272 = query_norm
   8      0.0570837 = field_weight(content:sphinx in 2), product of:
   9        1.0 = tf(term_freq(content:sphinx)=1)
  10        1.826679 = idf(doc_freq=6)
  11        0.03125 = field_norm(field=content, doc=2)
  12    0.3333333 = coord(1/3)

Tokenizers

acts_as_ferret

   1  
   2  class Story < ActiveRecord::Base
   3    acts_as_ferret :fields => { :title => { :boost => 4 }, 
   4                                :summary => { :boost => 2 },
   5                                :tag_list => { :boost => 1 } }
   6  end

Multiple concurrent writers

Should you use it?

Who’s using Ferret