Sha256: 22c1f9fc2b0a01e89cbe45492e5af0dedcd6db8a2223085a374a4099a20d2f3c

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 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 options [Hash] Options hash
        # @option [String, nil] :suffix 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 options [Hash] Options hash
        # @option [String] :suffix 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.4 lib/esse/backend/index/delete.rb