class Metacrunch::Elasticsearch::Destination
Constants
- DEFAULT_OPTIONS
Public Class Methods
new(elasticsearch_client, options = {})
click to toggle source
# File lib/metacrunch/elasticsearch/destination.rb, line 12 def initialize(elasticsearch_client, options = {}) @client = elasticsearch_client @options = DEFAULT_OPTIONS.deep_merge(options) @deprecator = ActiveSupport::Deprecation.new("5.0.0", "metacrunch-elasticsearch") if @options[:raise_on_result_errors] @deprecator.deprecation_warning("Option :raise_on_result_errors") end end
Public Instance Methods
close()
click to toggle source
# File lib/metacrunch/elasticsearch/destination.rb, line 34 def close # noop end
write(data)
click to toggle source
# File lib/metacrunch/elasticsearch/destination.rb, line 22 def write(data) return if data.blank? # Call elasticsearch bulk api bulk_options = @options[:bulk_options] bulk_options[:body] = data result = @client.bulk(bulk_options) # if the user provided a callback proc, call it @options[:result_callback].call(result) if @options[:result_callback]&.respond_to?(:call) end