Module: Elasticsearch::Persistence::Model::Utils

Defined in:
lib/elasticsearch/persistence/model/base.rb

Overview

Utility methods for Elasticsearch::Persistence::Model

Class Method Summary collapse

Class Method Details

.lookup_type(type) ⇒ Object

Return Elasticsearch type based on passed Ruby class (used in the ‘attribute` method)



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/elasticsearch/persistence/model/base.rb', line 74

def lookup_type(type)
  case
  when type == :keyword
    "keyword"
  when type == String
    "text"
  when type == Integer
    "integer"
  when type == Float
    "float"
  when type == Date || type == Time || type == DateTime
    "date"
  when type == Virtus::Attribute::Boolean
    "boolean"
  end
end