class AgnosticBackend::Elasticsearch::IndexField

Constants

TYPE_MAPPINGS

Attributes

name[R]
type[R]

Public Class Methods

new(name, type) click to toggle source
# File lib/agnostic_backend/elasticsearch/index_field.rb, line 19
def initialize(name, type)
  @name = name
  @type = type
end

Public Instance Methods

analyzed?() click to toggle source
# File lib/agnostic_backend/elasticsearch/index_field.rb, line 24
def analyzed?
  (type.type == AgnosticBackend::Indexable::FieldType::TEXT) ||
  (type.type == AgnosticBackend::Indexable::FieldType::TEXT_ARRAY)
end
analyzed_property() click to toggle source
# File lib/agnostic_backend/elasticsearch/index_field.rb, line 41
def analyzed_property
  analyzed? ? {} : { "index" => "not_analyzed" }
end
definition() click to toggle source
# File lib/agnostic_backend/elasticsearch/index_field.rb, line 33
def definition
  {
    name.to_s => {
      "type" => elasticsearch_type
    }.merge(analyzed_property)
  }
end
elasticsearch_type() click to toggle source
# File lib/agnostic_backend/elasticsearch/index_field.rb, line 29
def elasticsearch_type
  @elasticsearch_type ||= TYPE_MAPPINGS[type.type]
end