Sha256: 77d3428964a5c1668cb5dbcbff7504f9b2bee9674389c940de82eef8a417086a

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

module Mongoid
  module Elasticsearch
    class Index
      def initialize(es)
        @es = es
      end

      def klass
        @es.klass
      end

      def name
        klass.es_index_name
      end

      def type
        klass.es_index_type
      end

      def options
        klass.es_index_options
      end

      def indices
        @es.client.indices
      end

      def exists?
        indices.exists index: name
      end

      def create
        unless options == {} || exists?
          force_create
        end
      end

      def force_create
        indices.create index: name, body: options
      end

      def delete
        if exists?
          force_delete
        end
      end

      def force_delete
        indices.delete index: name
      end

      def refresh
        indices.refresh index: name
      end

      def reset
        delete
        create
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-elasticsearch-0.10.0 lib/mongoid/elasticsearch/index.rb