lib/esse/backend/index/create.rb in esse-0.0.2 vs lib/esse/backend/index/create.rb in esse-0.0.3
- old
+ new
@@ -8,37 +8,37 @@
alias: true,
}.freeze
# Creates index and applies mappings and settings.
#
- # UsersIndex.backend.create # creates index named `<prefix_>users_<suffix|index_version|timestamp>`
+ # UsersIndex.backend.create_index # creates index named `<prefix_>users_<suffix|index_version|timestamp>`
#
# @param options [Hash] Options hash
# @option options [Boolean] :alias Update `index_name` alias along with the new index
# @option options [String] :suffix The index suffix. Defaults to the `IndexClass#index_version` or
# `Esse.timestamp`. Suffixed index names might be used for zero-downtime mapping change.
# @return [Hash, false] the elasticsearch response or false in case of unsuccessful creation.
#
# @see http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/
- def create(suffix: nil, **options)
- create!(suffix: suffix, **options)
+ def create_index(suffix: nil, **options)
+ create_index!(suffix: suffix, **options)
rescue Elasticsearch::Transport::Transport::Errors::BadRequest
false
end
# Creates index and applies mappings and settings.
#
- # UsersIndex.backend.create! # creates index named `<prefix_>users_<suffix|index_version|timestamp>`
+ # UsersIndex.backend.create_index! # creates index named `<prefix_>users_<suffix|index_version|timestamp>`
#
# @param options [Hash] Options hash
# @option options [Boolean] :alias Update `index_name` alias along with the new index
# @option options [String] :suffix The index suffix. Defaults to the `IndexClass#index_version` or
# `Esse.timestamp`. Suffixed index names might be used for zero-downtime mapping change.
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when index already exists
# @return [Hash] the elasticsearch response
#
# @see http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/
- def create!(suffix: nil, **options)
+ def create_index!(suffix: nil, **options)
options = DEFAULT_OPTIONS.merge(options)
name = real_index_name(suffix)
definition = [settings_hash, mappings_hash].reduce(&:merge)
if options[:alias] && name != index_name