johnl / xapian-fu

A nicer Ruby interface for the Xapian full text indexer

This URL has Read+Write access

name age message
file LICENSE Loading commit data...
file README.rdoc
directory examples/
directory lib/
directory spec/
file xapian-fu.gemspec
README.rdoc

Xapian Fu

XapianFu is a Ruby library for working with Xapian databases. It builds on the GPL licensed Xapian Ruby bindings but provides an interface more in-line with "The Ruby Way"(tm).

Example

Create a database, add 3 documents to it and then search and retrieve them.

  db = XapianDb.new(:dir => 'example.db', :create => true,
                    :store => [:title, :year])
  db << { :title => 'Brokeback Mountain', :year => 2005 }
  db << { :title => 'Cold Mountain', :year => 2004 }
  db << { :title => 'Yes Man', :year => 2008 }
  db.search("mountain").each do |match|
    puts match.fields[:title]
  end

ActiveRecord Example

You could use it with something like ActiveRecord to index database records:

  db = XapianDb.new(:dir => 'posts.db', :create => true,
                    :store => :id)
  Post.all.each { db << p.attributes }
  db.search("custard").collect do |doc|
    Post.find(doc.id)
  end

More Info

Author:John Leach (john@johnleach.co.uk)
Copyright:Copyright © 2009 John Leach
License:GPL v2
Github:github.com/johnl/xapian-fu/tree/master