Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added r/w functionality to indexer and search, with read being the de…
…fault. set indexer to use write urls
  • Loading branch information
samdalton committed Sep 28, 2011
1 parent 0ef6746 commit f081691
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/solrsan/indexer.rb
Expand Up @@ -52,7 +52,7 @@ def index(doc)
else
raise "Indexed document must define a as_solr_document method."
end
self.perform_solr_command do |rsolr|
self.perform_solr_command(:write) do |rsolr|
rsolr.add(solr_docs)
end
end
Expand All @@ -65,7 +65,7 @@ def index_all

def destroy_index_document(doc)
if doc.respond_to?(:solr_id_value)
self.perform_solr_command do |rsolr|
self.perform_solr_command(:write) do |rsolr|
rsolr.delete_by_query("id:#{doc.solr_id_value}")
end
else
Expand All @@ -74,7 +74,7 @@ def destroy_index_document(doc)
end

def destroy_all_index_documents!
self.perform_solr_command do |rsolr|
self.perform_solr_command(:write) do |rsolr|
rsolr.delete_by_query("type:#{class_name}")
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/solrsan/search.rb
Expand Up @@ -12,12 +12,12 @@ def class_name
to_s.underscore
end

def solr
Solrsan::Config.instance.rsolr_object(@solr_server)
def solr(method = :read)
Solrsan::Config.instance.rsolr_object(@solr_server, method)
end

def perform_solr_command
yield(solr)
def perform_solr_command(method = :read)
yield(solr(method))
solr.commit
end

Expand Down

0 comments on commit f081691

Please sign in to comment.