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"}}

Source | Google | Stack overflow

Edit

git clone [email protected]:elastic/elasticsearch-ruby.git

cd elasticsearch-ruby

open elasticsearch-api/lib/elasticsearch/api/utils.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Elasticsearch--API--Utils-__bulkify-for-pr


# Commit to git

git add elasticsearch-api/lib/elasticsearch/api/utils.rbgit commit -m "better docs for Elasticsearch::API::Utils#__bulkify"


# Open pull request

gem 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!