diff --git a/lib/data_magic.rb b/lib/data_magic.rb index 1000d5cf..aa779e8b 100644 --- a/lib/data_magic.rb +++ b/lib/data_magic.rb @@ -227,6 +227,7 @@ def self.base_index_hash(es_index_name, es_types) # convert the types from data.yaml to Elasticsearch-specific types def self.es_field_types(field_types) custom_type = { + 'date' => {type: 'date', format: "yyyy-MM-dd"}, 'literal' => {type: 'string', index:'not_analyzed'}, 'name' => {type: 'string', index:'not_analyzed'}, 'lowercase_name' => {type: 'string', index:'not_analyzed', store: false}, diff --git a/spec/lib/data_magic_spec.rb b/spec/lib/data_magic_spec.rb index ecce7d89..0d1dfc59 100644 --- a/spec/lib/data_magic_spec.rb +++ b/spec/lib/data_magic_spec.rb @@ -24,6 +24,13 @@ end end + context 'with type "date"' do + it 'returns the date field with date type in default format' do + expect(described_class.es_field_types({ 'date' => 'date' })) + .to eq({"date"=>{:type=>"date",:format=>"yyyy-MM-dd"}}) + end + end + end end