Class: ObjectDsl

Inherits:
EsMigrationDsl show all
Defined in:
lib/wukong-migrate/elasticsearch_migration.rb

Instance Method Summary collapse

Methods inherited from EsMigrationDsl

#operation_list, template

Methods included from EsHttpOperation::Helpers

#alias_index_op, #create_index_op, #delete_index_op, #update_mapping_op, #update_settings_op

Methods inherited from Wukong::Migration::Dsl

define, perform

Methods included from Gorillib::Builder

#getset, #getset_collection_item

Instance Method Details

#mapping_rulesObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 43

def mapping_rules
  {}.tap do |rules|
    rules[:dynamic]    = dynamic                         if attribute_set?(:dynamic)
    rules[:_all]       = { enabled: all                } if attribute_set?(:all)
    rules[:_source]    = { enabled: source             } if attribute_set?(:source)
    rules[:_ttl]       = { enabled: true, default: ttl } if attribute_set?(:ttl)
    rules[:_timestamp] = { enabled: timestamp          } if attribute_set?(:timestamp)
    rules[:_analyzer]  = { path: analyzer_field        } if attribute_set?(:analyzer_field)
    rules[:_boost]     = { name: boost_field           } if attribute_set?(:boost_field)
    rules[:_parent]    = { type: parent                } if attribute_set?(:parent)
    rules[:_routing]   = { path: routing               } if attribute_set?(:routing)
  end
end

#model_mappingObject



57
58
59
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 57

def model_mapping
  name.to_s.camelize.constantize.to_mapping
end

#to_mappingObject



61
62
63
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 61

def to_mapping
  model_mapping.merge(mapping_rules)
end