Class: Elastic::Fields::Nested

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/elastic/fields/nested.rb', line 3

def index
  @index
end

#nameObject (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_inferenceObject



26
27
28
# File 'lib/elastic/fields/nested.rb', line 26

def disable_mapping_inference
  # does nothing, inference is always disabled
end

#freezeObject



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_optionsObject



35
36
37
# File 'lib/elastic/fields/nested.rb', line 35

def mapping_options
  @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!(_options)
  # does nothing
end

#needs_inference?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/elastic/fields/nested.rb', line 18

def needs_inference?
  false
end

#nested?Boolean

Returns:

  • (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

#validateObject



14
15
16
# File 'lib/elastic/fields/nested.rb', line 14

def validate
  nil
end