class ElasticSearch::BulkRequest
Public Class Methods
new(client)
click to toggle source
Create a new index request.
Calls superclass method
ElasticSearch::Request::new
# File lib/jruby-elasticsearch/bulkrequest.rb, line 7 def initialize(client) @client = client @prep = @client.prepareBulk() super() end
Public Instance Methods
<<(request)
click to toggle source
# File lib/jruby-elasticsearch/bulkrequest.rb, line 40 def <<(request) @prep.add(request) end
execute(&block)
click to toggle source
Execute this index request. This call is asynchronous.
If a block is given, register it for both failure and success.
# File lib/jruby-elasticsearch/bulkrequest.rb, line 17 def execute(&block) use_callback(&block) if block_given? action = @prep.execute(@handler) return action end
execute!()
click to toggle source
Execute this index request synchronously
# File lib/jruby-elasticsearch/bulkrequest.rb, line 25 def execute! return @prep.execute.actionGet() end
index(index, type, id=nil, data={})
click to toggle source
Index a document.
# File lib/jruby-elasticsearch/bulkrequest.rb, line 31 def index(index, type, id=nil, data={}) req = org.elasticsearch.action.index.IndexRequest.new(index) req.type(type) if type req.id(id.to_s) if id req.source(data) @prep.add(req) end