Skip to content

Using action_count or request_size swallows bulk response #92

Closed

Description

@grantr

Normally a bulk request returns the bulk response:

client.bulk do |bulk_request|
  bulk_request.index({"foo" => "bar"}, :id => '1', :index => 'test', :type => 'test')
end

=> {"took"=>61, "errors"=>false, "items"=>[{"index"=>{"_index"=>"test", "_type"=>"test", "_id"=>"1", "_version"=>1, "status"=>201}}]}

When using the :action_count or :request_size options to chunk bulk requests behind the scenes, the response is lost:

client.bulk(:action_count => 1) do |bulk_request|
  bulk_request.index({"foo" => "bar"}, :id => '1', :index => 'test', :type => 'test')
  bulk_request.index({"foo" => "bar"}, :id => '2', :index => 'test', :type => 'test')
end

=> nil

I think when :action_count or :request_size are used, the return value should be an array of response hashes.

I can't decide what the return value should be if no requests are made. The non-chunking bulk returns nil, but maybe the chunking version should return an empty array.

Is it worth making the multiple-request bulk helper a separate class? We use it heavily, so changing it would be painful, but it has opinions about how to handle multiple requests that maybe don't belong in the single-request bulk helper. Perhaps we could move it to a utility gem and supplement it with other tools like a standard scan/bulk looper.

Activity

  1. chrismwendt commented on Sep 23, 2015

    @chrismwendt
    Contributor
  2. grantr commented on Sep 23, 2015

    @grantr
    ContributorAuthor

    Fixed by #112.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions