README.rdoc in xapian_db-0.5.7 vs README.rdoc in xapian_db-0.5.8
- old
+ new
@@ -114,10 +114,18 @@
blueprint.attributes :name, :first_name, :profession
blueprint.index :notes, :remarks, :cv
blueprint.ignore_if {active == false}
end
+You can override the global adapter configuration in a specific blueprint. Let's say you use ActiveRecord, but you have
+one more class that is not stored in the database, but you want it to be indexed:
+
+XapianDb::DocumentBlueprint.setup(SpecialClass) do |blueprint|
+ blueprint.adapter :generic
+ blueprint.index :some_stuff
+end
+
place these configurations either into the corresponding class or - I prefer to have the index configurations outside
the models - into the file config/xapian_blueprints.rb.
=== Update the index
@@ -223,9 +231,19 @@
facets.each do |name, count|
puts "#{name}: #{count} hits"
end
At the class level, any attribute can be used for a facet query.
+
+=== Transactions
+
+You can execute a block of code inside a XapianDb transaction. This ensures that the changed objects in your block will get reindexed
+only if the block does not raise an exception.
+
+ XapianDb.transaction do
+ object1.save
+ object2.save
+ end
== Production setup
Since Xapian allows only one database instance to write to the index, the default setup of XapianDb will not work
with multiple app instances trying to write to the same database (you will get lock errors).