Class: Elastic::Fields::Nested
- Inherits:
-
Object
- Object
- Elastic::Fields::Nested
- Defined in:
- lib/elastic/fields/nested.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #disable_mapping_inference ⇒ Object
- #freeze ⇒ Object
- #get_field(_name) ⇒ Object
-
#initialize(_name, _index) ⇒ Nested
constructor
A new instance of Nested.
- #mapping_options ⇒ Object
- #merge!(_options) ⇒ Object
- #needs_inference? ⇒ Boolean
- #nested? ⇒ Boolean
- #prepare_value_for_index(_values) ⇒ Object
- #prepare_value_for_result(_values) ⇒ Object
- #select_aggregation(_from) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(_name, _index) ⇒ Nested
Returns a new instance of Nested.
5 6 7 8 |
# File 'lib/elastic/fields/nested.rb', line 5 def initialize(_name, _index) @name = _name.to_s @index = _index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/elastic/fields/nested.rb', line 3 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/elastic/fields/nested.rb', line 3 def name @name end |
Instance Method Details
#disable_mapping_inference ⇒ Object
26 27 28 |
# File 'lib/elastic/fields/nested.rb', line 26 def disable_mapping_inference # does nothing, inference is always disabled end |
#freeze ⇒ Object
30 31 32 33 |
# File 'lib/elastic/fields/nested.rb', line 30 def freeze @index.freeze_definition super end |
#get_field(_name) ⇒ Object
39 40 41 |
# File 'lib/elastic/fields/nested.rb', line 39 def get_field(_name) @index.definition.get_field _name end |
#mapping_options ⇒ Object
35 36 37 |
# File 'lib/elastic/fields/nested.rb', line 35 def @index.definition.as_es_mapping.merge!(type: :nested) end |
#merge!(_options) ⇒ Object
10 11 12 |
# File 'lib/elastic/fields/nested.rb', line 10 def merge!() # does nothing end |
#needs_inference? ⇒ Boolean
18 19 20 |
# File 'lib/elastic/fields/nested.rb', line 18 def needs_inference? false end |
#nested? ⇒ Boolean
22 23 24 |
# File 'lib/elastic/fields/nested.rb', line 22 def nested? true end |
#prepare_value_for_index(_values) ⇒ Object
43 44 45 |
# File 'lib/elastic/fields/nested.rb', line 43 def prepare_value_for_index(_values) _values.map { |v| @index.new(v).as_elastic_source } end |
#prepare_value_for_result(_values) ⇒ Object
47 48 49 50 |
# File 'lib/elastic/fields/nested.rb', line 47 def prepare_value_for_result(_values) formatter = Elastic::Core::SourceFormatter.new @index.definition _values.each { |v| formatter.format(v) } end |
#select_aggregation(_from) ⇒ Object
52 53 54 |
# File 'lib/elastic/fields/nested.rb', line 52 def select_aggregation(_from) nil end |
#validate ⇒ Object
14 15 16 |
# File 'lib/elastic/fields/nested.rb', line 14 def validate nil end |