Sha256: 2d784077b73c8bea1c5f3c9f788cca63d700f2fa44208227b9be67406ab84eb4

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

module Esse
  module Backend
    class Index
      module InstanceMethods
        # Performs the refresh operation in one or more indices.
        #
        # @note The refresh operation can adversely affect indexing throughput when used too frequently.
        # @param :suffix [String, nil] :suffix The index suffix. Defaults to the index_version.
        #   A uniq index name will be generated if one index already exist with the given alias.
        # @param options [Hash] Options hash
        # @raise [Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound]
        #   in case of failure
        # @return [Hash] the elasticsearch response
        #
        # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html
        def refresh!(suffix: index_version, **options)
          client.indices.refresh(
            options.merge(index: index_name(suffix: suffix)),
          )
        end

        # Performs the refresh operation in one or more indices.
        #
        # @note The refresh operation can adversely affect indexing throughput when used too frequently.
        # @param :suffix [String, nil] :suffix The index suffix. Defaults to the index_version.
        #   A uniq index name will be generated if one index already exist with the given alias.
        # @param options [Hash] Options hash
        # @return [Hash] the elasticsearch response, or an hash with 'errors' as true in case of failure
        #
        # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html
        def refresh(suffix: index_version, **options)
          refresh!(suffix: suffix, **options)
        rescue Elasticsearch::Transport::Transport::ServerError
          { 'errors' => true }
        end
      end

      include InstanceMethods
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
esse-0.2.0 lib/esse/backend/index/refresh.rb
esse-0.1.3 lib/esse/backend/index/refresh.rb
esse-0.1.2 lib/esse/backend/index/refresh.rb
esse-0.1.1 lib/esse/backend/index/refresh.rb