Class: Elos::Index::Mappings::Generator

Inherits:
Object
  • Object
show all
Includes:
Properties
Defined in:
lib/elos/index/mappings/generator.rb

Class Method Summary collapse

Class Method Details

.generate(mappings, fields:, physically_destroyable:, type_name:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/elos/index/mappings/generator.rb', line 4

def self.generate(mappings, fields:, physically_destroyable:, type_name:)
  fields ||= {}
  mappings = (mappings || {}).deep_dup
  mappings[:_all] = { enabled: false } unless mappings[:_all]
  properties = mappings[:properties] || {}
  properties[:_destroyed] = boolean_property unless physically_destroyable
  properties[:json] = no_index_string_property
  properties.reverse_merge!(fields)
  { type_name => mappings }
end