Browse files

Added support for multiple cores to solr update commands

  • Loading branch information...
1 parent 56b8e02 commit 77382b73f99bd4a4cfe9f66f0281fb60a844d2f3 @oxtralite oxtralite committed Aug 11, 2009
Showing with 16 additions and 3 deletions.
  1. +16 −3 lib/acts_as_solr/common_methods.rb
View
19 lib/acts_as_solr/common_methods.rb
@@ -52,17 +52,17 @@ def set_value_if_nil(field_type)
# Sends an add command to Solr
def solr_add(add_xml)
- ActsAsSolr::Post.execute(Solr::Request::AddDocument.new(add_xml))
+ ActsAsSolr::Post.execute(Solr::Request::AddDocument.new(add_xml), specified_core)
end
# Sends the delete command to Solr
def solr_delete(solr_ids)
- ActsAsSolr::Post.execute(Solr::Request::Delete.new(:id => solr_ids))
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:id => solr_ids), specified_core)
end
# Sends the commit command to Solr
def solr_commit
- ActsAsSolr::Post.execute(Solr::Request::Commit.new)
+ ActsAsSolr::Post.execute(Solr::Request::Commit.new, specified_core)
end
# Optimizes the Solr index. Solr says:
@@ -84,6 +84,19 @@ def record_id(object)
eval "object.#{object.class.primary_key}"
end
+ private
+
+ def specified_core
+ if solr_configuration[:multi_core]
+ begin
+ return self.locale.to_s
+ rescue NoMethodError
+ return solr_configuration[:default_core]
+ end
+ end
+ nil
+ end
+
end
end

0 comments on commit 77382b7

Please sign in to comment.