Class: SearchFlip::Bulk
- Inherits:
-
Object
- Object
- SearchFlip::Bulk
- Defined in:
- lib/search_flip/bulk.rb
Overview
The SearchFlip::Bulk class implements the bulk support, ie it collects single requests and emits batches of requests.
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#ignore_errors ⇒ Object
Returns the value of attribute ignore_errors.
-
#options ⇒ Object
Returns the value of attribute options.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#create(id, object, options = {}) ⇒ Object
Adds a create request to the bulk batch.
-
#delete(id, options = {}) ⇒ Object
Adds a delete request to the bulk batch.
-
#import(*args) ⇒ Object
Adds an index request to the bulk batch.
-
#index(id, object, options = {}) ⇒ Object
Adds an index request to the bulk batch.
-
#initialize(url, count = 1_000, options = {}) {|_self| ... } ⇒ Bulk
constructor
Builds and yields a new Bulk object, ie initiates the buffer, yields, sends batches of records each time the buffer is full, and sends a final batch after the yielded code returns and there are still documents present within the buffer.
-
#update(id, object, options = {}) ⇒ Object
Adds a update request to the bulk batch.
Constructor Details
#initialize(url, count = 1_000, options = {}) {|_self| ... } ⇒ Bulk
Builds and yields a new Bulk object, ie initiates the buffer, yields, sends batches of records each time the buffer is full, and sends a final batch after the yielded code returns and there are still documents present within the buffer.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/search_flip/bulk.rb', line 44 def initialize(url, count = 1_000, = {}) self.url = url self.count = count self. = self.ignore_errors = Array([:ignore_errors]).to_set if [:ignore_errors] init yield self upload if @num > 0 end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
17 18 19 |
# File 'lib/search_flip/bulk.rb', line 17 def count @count end |
#ignore_errors ⇒ Object
Returns the value of attribute ignore_errors.
17 18 19 |
# File 'lib/search_flip/bulk.rb', line 17 def ignore_errors @ignore_errors end |
#options ⇒ Object
Returns the value of attribute options.
17 18 19 |
# File 'lib/search_flip/bulk.rb', line 17 def end |
#url ⇒ Object
Returns the value of attribute url.
17 18 19 |
# File 'lib/search_flip/bulk.rb', line 17 def url @url end |
Instance Method Details
#create(id, object, options = {}) ⇒ Object
Adds a create request to the bulk batch.
83 84 85 |
# File 'lib/search_flip/bulk.rb', line 83 def create(id, object, = {}) perform :create, id, SearchFlip::JSON.generate(object), end |
#delete(id, options = {}) ⇒ Object
Adds a delete request to the bulk batch.
104 105 106 |
# File 'lib/search_flip/bulk.rb', line 104 def delete(id, = {}) perform :delete, id, nil, end |
#import(*args) ⇒ Object
Adds an index request to the bulk batch
72 73 74 |
# File 'lib/search_flip/bulk.rb', line 72 def import(*args) index(*args) end |
#index(id, object, options = {}) ⇒ Object
Adds an index request to the bulk batch.
64 65 66 |
# File 'lib/search_flip/bulk.rb', line 64 def index(id, object, = {}) perform :index, id, SearchFlip::JSON.generate(object), end |
#update(id, object, options = {}) ⇒ Object
Adds a update request to the bulk batch.
94 95 96 |
# File 'lib/search_flip/bulk.rb', line 94 def update(id, object, = {}) perform :update, id, SearchFlip::JSON.generate(object), end |