Class: Solr::Request::Delete
- Defined in:
- lib/solr/request/delete.rb
Overview
The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
-
#initialize(options) ⇒ Delete
constructor
A delete request can be for a specific document id.
- #to_s ⇒ Object
Methods inherited from Update
Methods inherited from Base
#content_type, #handler, #response_format
Constructor Details
#initialize(options) ⇒ Delete
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/solr/request/delete.rb', line 23 def initialize() unless .kind_of?(Hash) and ([:id] or [:query]) raise Solr::Exception.new("must pass in :id or :query") end if [:id] and [:query] raise Solr::Exception.new("can't pass in both :id and :query") end @document_id = [:id] @query = [:query] end |
Instance Method Details
#to_s ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/solr/request/delete.rb', line 34 def to_s delete_element = Solr::XML::Element.new('delete') if @document_id id_element = Solr::XML::Element.new('id') id_element.text = @document_id delete_element.add_element(id_element) elsif @query query = Solr::XML::Element.new('query') query.text = @query delete_element.add_element(query) end delete_element.to_s end |