Skip to content
Browse files

WIP batch insert support

  • Loading branch information...
1 parent c14b4fa commit ec8f4688f71b10e169ac456c54ac8487721251ed @santip santip committed Mar 10, 2011
Showing with 23 additions and 1 deletion.
  1. +23 −1 lib/indextank/index.rb
View
24 lib/indextank/index.rb
@@ -31,7 +31,7 @@ def refresh
@metadata = response.body
end
- response
+ response.body
end
def delete
@@ -56,6 +56,28 @@ def exists?
refresh.status != 404
end
+ def batch_insert(documents)
+ puts documents.to_json
+ resp = @conn.put do |req|
+ req.url "docs"
+ req.body = documents.to_json
+ end
+ case resp.status
+ when 200
+ nil
+ 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 ec8f468

Please sign in to comment.
Something went wrong with that request. Please try again.