Method: Elasticsearch::Persistence::Repository#mapping

Defined in:
lib/elasticsearch/persistence/repository.rb

#mapping(*args) ⇒ Elasticsearch::Model::Indexing::Mappings Also known as: mappings

Note:

If mappings were set when the repository was created, a block passed to this method will not be evaluated.

Get the index mapping. Optionally pass a block to define the mappings.

end

Examples:

repository.mapping

Set the mappings with a block.

repository.mapping dynamic: 'strict' do
  indexes :foo
end

Returns:

  • (Elasticsearch::Model::Indexing::Mappings)

    The index mappings.

Since:

  • 6.0.0

[View source]

165
166
167
168
169
170
171
# File 'lib/elasticsearch/persistence/repository.rb', line 165

def mapping(*args)
  @memoized_mapping ||= @options[:mapping] || (begin
    if _mapping = __get_class_value(:mapping)
      _mapping
    end
  end) || (super && @mapping)
end