class ObjectDsl

Public Instance Methods

mapping_rules() click to toggle source
# 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_mapping() click to toggle source
# File lib/wukong-migrate/elasticsearch_migration.rb, line 57
def model_mapping
  name.to_s.camelize.constantize.to_mapping
end
to_mapping() click to toggle source
# File lib/wukong-migrate/elasticsearch_migration.rb, line 61
def to_mapping
  model_mapping.merge(mapping_rules)
end