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

Returns a new instance of Async.

Parameters:



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.

Parameters:

  • query (Hash)

    The delete query

  • slices (Integer, String) (defaults to: 5)

    Number of slices to cut the operation into for faster processing (i.e., run the operation in parallel). Use “auto” to make elasticsearch decide how many slices to divide into

Returns:

  • (Concurrent::Promise)

    The eventual value returned from the single completion of the delete operation

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