module ClinicalTrials
  class Indexer

    def self.create_indexes
      Study.__elasticsearch__.delete_index!
      Study.__elasticsearch__.create_index!
      Study.__elasticsearch__.import
    end

  end
end

module ClinicalTrials
  class Indexer

    def self.create_indexes
      Study.__elasticsearch__.delete_index!  if Study.__elasticsearch__.index_exists?
      Study.__elasticsearch__.create_index!
      Study.__elasticsearch__.import
    end

  end
end

Check that index exists before trying to delete it
Check that index exists before trying to delete it