Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A nicer Ruby interface for the Xapian full text indexer

tag: release-0.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

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

Something went wrong with that request. Please try again.