Sha256: dda15fbeaeecba689187e7f747a4bba1ce9aa9f596b3040f7cb0c16d8987516d
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Esse class IndexType # https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html module ClassMethods # This method is only used to define mapping def mappings(hash = {}, &block) @mapping = Esse::IndexMapping.new(body: hash, paths: template_dirs, filenames: mapping_filenames) return unless block_given? @mapping.define_singleton_method(:as_json, &block) end # This is the actually content that will be passed through the ES api def mappings_hash hash = mapping.body { type_name => (hash.key?('properties') ? hash : { 'properties' => hash }), } end private def mapping @mapping ||= Esse::IndexMapping.new(paths: template_dirs, filenames: mapping_filenames) end def template_dirs return [] unless respond_to?(:index) index.template_dirs end def mapping_filenames Esse::IndexMapping::FILENAMES.map { |str| [type_name, str].join('_') } 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_type/mappings.rb |
esse-0.0.4 | lib/esse/index_type/mappings.rb |
esse-0.0.3 | lib/esse/index_type/mappings.rb |