Class: ElasticSearch::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby-elasticsearch/request.rb

Instance Method Summary collapse

Constructor Details

#initializeRequest

Create a new index request.



6
7
8
# File 'lib/jruby-elasticsearch/request.rb', line 6

def initialize
  @handler = ElasticSearch::ActionListener.new
end

Instance Method Details

#on(event, &block) ⇒ Object

See ElasticSearch::ActionListener#on



11
12
13
14
15
# File 'lib/jruby-elasticsearch/request.rb', line 11

def on(event, &block)
  #puts "Event[#{event}] => #{block} (#{@handler})"
  @handler.on(event, &block)
  return self
end

#use_callback(&block) ⇒ Object

Execute this index request. This call is asynchronous.

If a block is given, register it for both failure and success.



21
22
23
24
25
26
# File 'lib/jruby-elasticsearch/request.rb', line 21

def use_callback(&block)
  if block_given?
    on(:failure, &block)
    on(:success, &block)
  end
end