in DataMapper

Index your DataMapper Models with Xapian

Still pretty preliminary, but the basics seem to work. dm-xapian is a Merb plugin to index your DataMapper models with Xapian

At this point the details are still sketchy, and you first need to install xapian, then the xapian ruby bindings: Install Xapian and ruby bindings

Then it gets easier:

* build the gem with
rake install
* add the dependency
dependencies "dm-xapian"
* create the dm-xapian resource
rake dm:autoupgrade
* tell dm-xapian to index your models (Er, Resources) with something like:

is_indexed :texts => [ :name, :region, :country, :varietal ],
:values => [[:price, 0, "price", :float], [:ean, 1, "ean", :string]],
:terms => [ [ :winery, 'W', "winery" ] ]

* build the index with
rake xapian:rebuild_index models="Wine Winery"
* build the index with
rake xapian:update_index models="Wine Winery"
This will remove from the index any model destroyed or update any model since the last call to xapian:rebuild_index or xapian:update_index
* Run a query
rake xapian:query query="edited 6" models="Wine Winery" verbose=true limit=25

Of course, running a query via rake is not so useful, but that’s all I tried so far. But at least this proved that the index was built correctly, and integrated search to an app is next.

As you may have noticed already, a big thing lacking at this point are specs.

This is in collaboration with Joshaven and based on the awesome work by Francis Irving on act_as_xapian who created the Rails+ActiveRecord version.

  1. Oh, one thing I forgot to mention: I’m not sure whether this is something that should go in dm-more, or stay as its own separate plugin. Thoughts welcome of course!

  2. Pascal, I think something like this should definately make it into dm-more. It will get much better usage by the community, and will be kept in sync with DataMapper changes (before committing to dm-core, it’s required to make sure the specs for each dm-more plugin pass too).

    There is some question as to whether at some point dm-more will be further subdivided. I can’t answer that right now, but I do know that in the near term you’re likely to get alot more usage and feedback if it’s a part of dm-more than you will flying solo.

  3. Thanks for the input Dan! I really appreciate it.

    I guess we better add some specs first then.

    Once there are enough of then, I’ll get back to you. Sadly, acts_as_xapian did not include any and I’ve mostly relied on the rake tasks for testing. The same functionality should be enough as specs.

    The bigger issue, which worries me most, is about adding the requirement to both xapian and xapian bindings that only have readily available packages on linux, even though it compiles very easily on the mac, but I have no ideas how it works out on windows.

Comments are closed.