README.rdoc in xapian_db-1.3.5.4 vs README.rdoc in xapian_db-1.3.7

- old
+ new

@@ -30,13 +30,13 @@ <b>If you found a bug or are looking for a missing feature, please post to the {Google Group}[http://groups.google.com/group/xapian_db]</b> == Requirements -* ruby 1.9.2 or newer +* ruby 2.0.0 or newer * rails 3.0 or newer (if you want to use it with rails) -* xapian-core and xapian-ruby binaries installed +* xapian-core and xapian-ruby binaries 1.2.x installed == Installing xapian binaries On OSX, I recommend to install the binaries using homebrew like so: brew install xapian --ruby. Another option is to install and require the xapian-ruby gem; this works for linux, too. Make sure to add the gem to your Gemfile in this case. @@ -192,10 +192,36 @@ blueprint.natural_sort_order do "#{surname} #{name}" end end +You can specify a Ruby method for preprocessing the indexed terms. The method needs to be a class method that takes one argument (the terms to be indexed) and +returns a string. You can configure it globaly in the config or on a blueprint. For example, this setup will make words with accented e characters searchable +by their accentless form: + + class Util + def self.strip_accents(terms) + terms.gsub(/[éèêëÉÈÊË]/, "e") + end + end + + XapianDb::Config.setup do |config| + config.indexer_preprocess_callback UtilT.method(:strip_accents) + end + +You may use attributes from associated objects in a blueprint; if you do that and an associated object is updated, your objects should be reindexed, too. You can tell XapnaDB about those dependencies like so: + + XapianDb::DocumentBlueprint.setup(:Person) do |blueprint| + blueprint.attribue :address, :as => :json + + blueprint.dependency :Address, when_changed: %i(street zip city) do |address| + Person.joins{ address }.where{ adresses.id == my{ address.id } } + end + end + +The block you supply to the dependency declaration must return a collection of objects that should get reindexed, too. + If you want to manage the (re)indexing of your objects on your own, turn off autoindexing in your blueprint: XapianDb::DocumentBlueprint.setup(:Person) do |blueprint| blueprint.autoindex false end @@ -243,9 +269,13 @@ results = XapianDb.search "fo* or baz" You can query attributes: results = XapianDb.search "name:Foo" + +You can force the sort order: + + results = XapianDb.search "name:Foo", order: [:name] You can query objects of a specific class: results = Person.search "name:Foo"