Sha256: 78808354af1e6a122d8a39826527f62f72cc3e72994081fd8b916fa4a8dae44a
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true # The es 7.6 deprecate the mapping definition under the type level. That's why we have option # to define mappings under both Type and Index. If the index mapping is defined. All the Type # mapping will be ignored. # Source: https://www.elastic.co/guide/en/elasticsearch/reference/7.6/removal-of-types.html module Esse class Index module ClassMethods # This is the actually content that will be passed through the ES api def mappings_hash { Esse::MAPPING_ROOT_KEY => (index_mapping || type_mapping) } end # This method is only used to define mapping def mappings(hash = {}, &block) @mapping = Esse::IndexMapping.new(body: hash, paths: template_dirs) return unless block_given? @mapping.define_singleton_method(:as_json, &block) end private def mapping @mapping ||= Esse::IndexMapping.new(paths: template_dirs) end def index_mapping return if mapping.empty? hash = mapping.body hash.key?(Esse::MAPPING_ROOT_KEY) ? hash[Esse::MAPPING_ROOT_KEY] : hash end def type_mapping return {} if type_hash.empty? type_hash.values.map(&:mappings_hash).reduce(&:merge) end end extend ClassMethods end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
esse-0.0.5 | lib/esse/index/mappings.rb |
esse-0.0.4 | lib/esse/index/mappings.rb |
esse-0.0.3 | lib/esse/index/mappings.rb |