Sha256: c3c6cd3bc0637056f091478623b52122ac5ddb0202cbda192b830a1569d34e57

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Esse
  module Backend
    class Index
      module InstanceMethods
        # Deletes ES index
        #
        #   UsersIndex.backend.delete_index! # deletes `<prefix_>users<_suffix|_index_version|_timestamp>` index
        #
        # @param suffix [String, nil] The index suffix Use nil if you want to delete the current index.
        # @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when index does not exists
        # @return [Hash] elasticsearch response
        def delete_index!(suffix:)
          client.indices.delete(index: index_name(suffix: suffix))
        end

        # Deletes ES index
        #
        #   UsersIndex.backend.delete_index # deletes `<prefix_>users<_suffix|_index_version|_timestamp>` index
        #
        # @param suffix [String, nil] The index suffix Use nil if you want to delete the current index.
        # @return [Hash, false] elasticsearch response, of false in case of error.
        def delete_index(suffix: index_version)
          delete_index!(suffix: suffix)
        rescue Elasticsearch::Transport::Transport::Errors::NotFound
          false
        end
      end

      include InstanceMethods
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esse-0.0.5 lib/esse/backend/index/delete.rb