class Solr::Request::AtomicUpdate
Public Class Methods
new(update_docs)
click to toggle source
Example: Solr::Request::AtomicUpdate.new
([:id => 10, :set => {:field_name => “new value”}])
# File lib/solr/request/atomic_update.rb, line 3 def initialize(update_docs) @docs = [] update_docs.each do |update_doc| doc = {} [:set, :add, :remove, :removeregex, :inc].each do |mode| field_data = update_doc[mode] if field_data field_data.each do |field_name, field_value| doc[field_name] = {mode => field_value} if field_value end update_doc.delete mode end end doc[update_doc.keys[0].to_s] = update_doc.values[0] @docs << doc end end
Public Instance Methods
content_type()
click to toggle source
# File lib/solr/request/atomic_update.rb, line 21 def content_type 'application/json; charset=utf-8' end
to_s()
click to toggle source
returns the request as a string suitable for posting
# File lib/solr/request/atomic_update.rb, line 26 def to_s return @docs.to_json end