Class: Solr::Request::ModifyDocument
- Defined in:
- lib/solr/request/modify_document.rb
Instance Method Summary collapse
- #handler ⇒ Object
-
#initialize(update_data) ⇒ ModifyDocument
constructor
Example: ModifyDocument.new(:id => 10, :overwrite => => “new value”).
-
#to_s ⇒ Object
returns the request as a string suitable for posting.
Methods inherited from Update
Methods inherited from Base
#content_type, #response_format
Constructor Details
#initialize(update_data) ⇒ ModifyDocument
Example: ModifyDocument.new(:id => 10, :overwrite => => “new value”)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/solr/request/modify_document.rb', line 21 def initialize(update_data) modes = [] @doc = {} [:overwrite, :append, :distinct, :increment, :delete].each do |mode| field_data = update_data[mode] if field_data field_data.each do |field_name, field_value| modes << "#{field_name}:#{mode.to_s.upcase}" @doc[field_name] = field_value if field_value # if value is nil, omit so it can be removed end update_data.delete mode end end @mode = modes.join(",") # only one key should be left over, the id @doc[update_data.keys[0].to_s] = update_data.values[0] end |
Instance Method Details
#handler ⇒ Object
47 48 49 |
# File 'lib/solr/request/modify_document.rb', line 47 def handler "update?mode=#{@mode}" end |