Module: Elasticsearch::Model::Serializing::InstanceMethods

Included in:
Proxy::InstanceMethodsProxy
Defined in:
lib/elasticsearch/model/serializing.rb

Instance Method Summary collapse

Instance Method Details

#as_indexed_json(options = {}) ⇒ Hash

Serialize the record as a Hash, to be passed to the client.

Re-define this method to customize the serialization.

Examples:

Return the model instance as a Hash


Article.first.__elasticsearch__.as_indexed_json
=> {"title"=>"Foo"}

Returns:

  • (Hash)

See Also:



43
44
45
46
# File 'lib/elasticsearch/model/serializing.rb', line 43

def as_indexed_json(options={})
  # TODO: Play with the `MyModel.indexes` method -- reject non-mapped attributes, `:as` options, etc
  self.as_json(options.merge root: false)
end