Permalink
Browse files

bulk delete

  • Loading branch information...
1 parent 7e5e563 commit e7797961213199bd78a21a9a96182bbac2e0f1c0 Leandro Oniszczuk committed Jun 2, 2011
Showing with 26 additions and 0 deletions.
  1. +26 −0 lib/indextank/index.rb
View
26 lib/indextank/index.rb
@@ -77,6 +77,32 @@ def batch_insert(documents)
end
end
+ def bulk_delete(docids)
+ data = []
+ docids.each do |docid|
+ data << {'docid': docid}
+ end
+ resp = @conn.put do |req|
+ req.url "docs"
+ req.body = data.to_json
+ end
+ case resp.status
+ when 200
+ resp.body
+ when 401
+ raise InvalidApiKey
+ when 409
+ raise IndexInitializing
+ when 404
+ raise NonExistentIndex
+ when 400
+ raise InvalidArgument, resp.body
+ else
+ raise UnexpectedHTTPException, resp.body
+ end
+ end
+
+
# the options argument may contain an :index_code definition to override
# this instance's default index_code
# it can also contain any of the following:

0 comments on commit e779796

Please sign in to comment.