create_index!

in elasticsearch-model/lib/elasticsearch/model/indexing.rb [231:249]


        def create_index!(options={})
          options = options.clone

          target_index = options.delete(:index)    || self.index_name
          settings     = options.delete(:settings) || self.settings.to_hash
          mappings     = options.delete(:mappings) || self.mappings.to_hash

          delete_index!(options.merge index: target_index) if options[:force]

          unless index_exists?(index: target_index)
            options.delete(:force)
            self.client.indices.create({ index: target_index,
                                         body: {
                                           settings: settings,
                                           mappings: mappings }
                                       }.merge(options))
          end
        end