aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb8
-rw-r--r--vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake6
2 files changed, 11 insertions, 3 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 9ee65cba2..2279c2e66 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: acts_as_xapian.rb,v 1.6 2008-04-24 09:49:32 francis Exp $
+# $Id: acts_as_xapian.rb,v 1.7 2008-04-24 09:57:48 francis Exp $
# TODO:
# Spell checking
@@ -375,10 +375,11 @@ module ActsAsXapian
end
# You must specify *all* the models here, this totally rebuilds the Xapian database.
+ # You'll want any readers to reopen the database after this.
def ActsAsXapian.rebuild_index(model_classes)
raise "when rebuilding all, please call as first and only thing done in process / task" if not ActsAsXapian.writable_db.nil?
- # Delete existing new database, and open a new one
+ # Delete any existing .new database, and open a new one
new_path = ActsAsXapian.db_path + ".new"
if File.exist?(new_path)
raise "found existing " + new_path + " which is not Xapian flint database, please delete for me" if not File.exist?(File.join(new_path, "iamflint"))
@@ -411,6 +412,9 @@ module ActsAsXapian
raise "old database now at " + temp_path + " is not Xapian flint database, please delete for me" if not File.exist?(File.join(temp_path, "iamflint"))
FileUtils.rm_rf(temp_path)
end
+
+ # You'll want to restart your FastCGI or Mongrel processes after this,
+ # so they get the new db
end
######################################################################
diff --git a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake
index 661c59be8..d9578a2cc 100644
--- a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake
+++ b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake
@@ -12,13 +12,17 @@ namespace :xapian do
# Parameters - specify 'models="PublicBody User"' to say which models
# you index with Xapian.
+ # This totally rebuilds the database, so you will want to restart any
+ # web server afterwards to make sure it gets the changes, rather than
+ # still pointing to the old deleted database.
desc 'Completely rebuilds Xapian search index (must specify all models)'
task :rebuild_index do
raise "specify ALL your models with models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil?
ActsAsXapian.rebuild_index(ENV['models'].split(" ").map{|m| m.constantize})
end
- # Parameters - are models, query, first_result, results_per_page, sort_by_prefix, collapse_by_prefix
+ # Parameters - are models, query, first_result, results_per_page,
+ # sort_by_prefix, collapse_by_prefix
desc 'Run a query, return YAML of results'
task :query do
raise "specify models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil?