Class: JayAPI::Elasticsearch::Async

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jay_api/elasticsearch/async.rb

Overview

Provides functionality to perform asynchronous operations on an elasticsearch index. For more information: ruby-concurrency.github.io/concurrent-ruby/1.3.4/Concurrent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Async



24
25
26
# File 'lib/jay_api/elasticsearch/async.rb', line 24

def initialize(index)
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



18
19
20
# File 'lib/jay_api/elasticsearch/async.rb', line 18

def index
  @index
end

Instance Method Details

#delete_by_query(query, slices: 5) ⇒ Concurrent::Promise

Deletes asynchronously the documents matching the given query from the Index.

Raises:

See Also:

  • for more info


41
42
43
44
45
46
47
48
# File 'lib/jay_api/elasticsearch/async.rb', line 41

def delete_by_query(query, slices: 5)
  Concurrent::Promise.execute do
    async_response = index.delete_by_query(query, slices: slices, wait_for_completion: false)
    result = tasks.by_id(async_response[:task])
    validate_result(result)
    result
  end
end