Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1.33 KB

README.textile

File metadata and controls

40 lines (27 loc) · 1.33 KB

Xapor

Description

Pronounced ‘zap-or’. A Xapian rails plugin, designed to integrate XapianFu into ActiveRecord in a nicer,
simpler fashion.

Usage

To add an index to a model, simply add a block like the following:

class SomeModel < ActiveRecord::Base
  xapor do |idx|
    idx.search :name
    idx.search :description
  end
end

This will create an in-memory index for the model. It will also automatically index all the items currently in the
table and add and remove items from the index as they are created, updated and removed.

Once you have added xapor to a model, you can then search it by doing:

SomeModel.search("Some search query")

This returns a XapianFu result set, which can be easily turned into AR models with a block like the following:

results = []
SomeModel.search("Text").each do |result|
  results << SomeModel.find(result.id)
end

TODO

  • Get the indexing working with disk-based Xapian indexes
  • Sort out the ability to store and retrieve extra item data in the index and remove the need to load data from the database on every search
  • Add the ability to put in a ‘xapor.yml’ config file to define environment specific index settings (e.g. use memory in testing, and a different directory prefix in dev and prod)

Copyright

Copyright © 2010 Hedtek Ltd. See LICENSE for details.