Method: ElasticSearch::Index#add
- Defined in:
- lib/elasticsearch.rb
#add(type, id, doc, params = {}) ⇒ Object
Add a document to this index
type - the type of this document
id - the unique identifier for this document
doc - the document to be indexed
Returns a hash, the parsed response body from elasticsearch
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/elasticsearch.rb', line 137 def add(type, id, doc, params={}) doc.each do |key, val| # make sure dates are in a consistent format for indexing doc[key] = val.iso8601 if val.respond_to?(:iso8601) end put do |req| req.url "/#{@name}/#{type}/#{id}", params req.body = doc end end |