Class: AgnosticBackend::Elasticsearch::IndexField
- Inherits:
-
Object
- Object
- AgnosticBackend::Elasticsearch::IndexField
- Defined in:
- lib/agnostic_backend/elasticsearch/index_field.rb
Constant Summary collapse
- TYPE_MAPPINGS =
{ AgnosticBackend::Indexable::FieldType::STRING => "string", AgnosticBackend::Indexable::FieldType::STRING_ARRAY => "string", AgnosticBackend::Indexable::FieldType::DATE => "date", AgnosticBackend::Indexable::FieldType::DATE_ARRAY => "date", AgnosticBackend::Indexable::FieldType::INTEGER => "integer", AgnosticBackend::Indexable::FieldType::DOUBLE => "double", AgnosticBackend::Indexable::FieldType::BOOLEAN => "boolean", AgnosticBackend::Indexable::FieldType::TEXT => "string", AgnosticBackend::Indexable::FieldType::TEXT_ARRAY => "string", }.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #analyzed? ⇒ Boolean
- #analyzed_property ⇒ Object
- #definition ⇒ Object
- #elasticsearch_type ⇒ Object
-
#initialize(name, type) ⇒ IndexField
constructor
A new instance of IndexField.
Constructor Details
#initialize(name, type) ⇒ IndexField
Returns a new instance of IndexField.
19 20 21 22 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 19 def initialize(name, type) @name = name @type = type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 17 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 17 def type @type end |
Instance Method Details
#analyzed? ⇒ Boolean
24 25 26 27 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 41 def analyzed_property analyzed? ? {} : { "index" => "not_analyzed" } end |
#definition ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 33 def definition { name.to_s => { "type" => elasticsearch_type }.merge(analyzed_property) } end |
#elasticsearch_type ⇒ Object
29 30 31 |
# File 'lib/agnostic_backend/elasticsearch/index_field.rb', line 29 def elasticsearch_type @elasticsearch_type ||= TYPE_MAPPINGS[type.type] end |