Docunext


Ruby Xapian Fu

April 26th, 2010

Ruby has been a joy for me to learn and that positive experience has led me to try certain tasks I had previously hesitated to undertake.

Building a Xapian database for searching, for instance. I first tried using the standard Xapian bindings, but then I found xapian-fu, a much more Rubyish gem.

It works fine with ruby 1.9.1 for me and is quite speedy. Here's a very simple example for a search (using the databases generated by the debian package apt-xapian-index):

#!/usr/bin/ruby1.9.1
require 'xapian-fu'
include XapianFu
db = XapianDb.new(:dir => '/var/lib/apt-xapian-index/index.1')
db.search(ARGV[0]).each do |match|
  puts match.data
end
Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022