Class: Fields

Inherits:
Object
  • Object
show all
Defined in:
lib/es_fields/fields.rb

Constant Summary collapse

BASE_MAPPING =
{
  "mappings": {
    "doc": {
      "properties": {
      }
    }
  }
}
TYPE_MAPPING =
{
  string: 'text',
  long: 'long',
  date: 'date',
  keyword: 'keyword',
  double: 'double',
  boolean: 'boolean',
  ip: 'ip',
}

Instance Method Summary collapse

Constructor Details

#initializeFields

Returns a new instance of Fields.



22
23
24
# File 'lib/es_fields/fields.rb', line 22

def initialize
  @base_mapping = BASE_MAPPING.dup
end

Instance Method Details

#field(name, type) ⇒ Object



26
27
28
29
30
31
# File 'lib/es_fields/fields.rb', line 26

def field(name, type)
  @base_mapping[:mappings][:doc][:properties].merge!(
    { name => { type: TYPE_MAPPING[type]}}
  )
  @base_mapping
end