elasticsearch-ruby
https://github.com/elastic/elasticsearch-ruby
Ruby
Ruby integrations for Elasticsearch
Elasticsearch::API::Utils#__bulkify
Convert an array of payloads into Elasticsearch `header\ndata` format
Supports various different formats of the payload: Array of Strings, Header/Data pairs,
or the conveniency "combined" format where data is passed along with the header
in a single item.
Elasticsearch::API::Utils.__bulkify [
{ :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } },
{ :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } }
]
# => {"index":{"_index":"myindexA","_type":"mytype","_id":"1"}}
# => {"title":"Test"}
# => {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}}
# => {"doc":{"title":"Update"}}Edit
git clone [email protected]:elastic/elasticsearch-ruby.git
cd elasticsearch-ruby
open elasticsearch-api/lib/elasticsearch/api/utils.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Elasticsearch--API--Utils-__bulkify-for-pr
# Commit to gitgit add elasticsearch-api/lib/elasticsearch/api/utils.rbgit commit -m "better docs for Elasticsearch::API::Utils#__bulkify"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Elasticsearch--API--Utils-__bulkify-for-pr
hub pull-request
# Celebrate!