Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk API: Fix return of wrong request type on failed updates #6630

Closed
tuxnco opened this issue Jun 26, 2014 · 0 comments · Fixed by #6646
Closed

Bulk API: Fix return of wrong request type on failed updates #6630

tuxnco opened this issue Jun 26, 2014 · 0 comments · Fixed by #6646
Assignees
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v1.2.2 v1.3.0 v2.0.0-beta1

Comments

@tuxnco
Copy link

tuxnco commented Jun 26, 2014

Opening an issue as suggested by @dadoonet after the following discussion on the mailing list: https://groups.google.com/forum/#!topic/elasticsearch/HAA4Y8Qziqg

When a bulk update action fails, an "index" entry can be returned in the response.

Example bulk commands list with an update command failing because the second date can't be parsed:

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } 
{ "title" : "Great Title of doc 1" } 
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } 
{ "title" : "Great Title of doc 2" } 
{ "update" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } 
{ "doc" : { "date" : "2014-04-30T23:59:57" }} 
{ "update" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } 
{ "doc" : { "date" : "2014-04-31T00:00:01" }} 
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } 
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }

Here is the actual response (elasticsearch v1.1):

{
  "took" : 4, 
  "errors" : true, 
  "items" : [ { 
    "index" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 8, 
      "status" : 201 
    } 
  }, { 
    "index" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "_version" : 5, 
      "status" : 201 
    } 
  }, { 
    "update" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 9, 
      "status" : 200 
    } 
  }, { 
    "index" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "status" : 400, 
      "error" : "MapperParsingException[failed to parse [date]]; nested: MapperParsingException[failed to parse date field [2014-04-31T00:00:01], tried both date format [dateOptionalTime], and timestamp number with locale []]; nested: IllegalFieldValueException[Cannot parse \"2014-04-31T00:00:01\": Value 31 for dayOfMonth must be in the range [1,30]]; " 
    } 
  }, { 
    "delete" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 10, 
      "status" : 200, 
      "found" : true 
    } 
  }, { 
    "delete" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "_version" : 6, 
      "status" : 200, 
      "found" : true 
    } 
  } ] 
}

The problem here concerns the bulk update response for the forth item. It's key is index while it should be update, as in the following hand edited response:

{
  "took" : 4, 
  "errors" : true, 
  "items" : [ { 
    "index" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 8, 
      "status" : 201 
    } 
  }, { 
    "index" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "_version" : 5, 
      "status" : 201 
    } 
  }, { 
    "update" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 9, 
      "status" : 200 
    } 
  }, { 
    "update" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "status" : 400, 
      "error" : "MapperParsingException[failed to parse [date]]; nested: MapperParsingException[failed to parse date field [2014-04-31T00:00:01], tried both date format [dateOptionalTime], and timestamp number with locale []]; nested: IllegalFieldValueException[Cannot parse \"2014-04-31T00:00:01\": Value 31 for dayOfMonth must be in the range [1,30]]; " 
    } 
  }, { 
    "delete" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "1", 
      "_version" : 10, 
      "status" : 200, 
      "found" : true 
    } 
  }, { 
    "delete" : { 
      "_index" : "test", 
      "_type" : "type1", 
      "_id" : "2", 
      "_version" : 6, 
      "status" : 200, 
      "found" : true 
    } 
  } ] 
}

I didn't do a lot of code reading but a possible starting point for investigations is there: https://github.com/elasticsearch/elasticsearch/blob/1.1/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java#L317

@areek areek assigned rjernst and unassigned rjernst Jun 29, 2014
@spinscale spinscale self-assigned this Jun 30, 2014
@spinscale spinscale changed the title Bulk API: inconsistent data in response to failing bulk update commands Bulk API: Fix return of wrong request type on failed updates Jul 2, 2014
spinscale added a commit to spinscale/elasticsearch that referenced this issue Jul 2, 2014
In case an update request failed (for example when updating with a
wrongly formatted date), the returned index operation type was index
instead of update.

Closes elastic#6630
spinscale added a commit that referenced this issue Jul 2, 2014
In case an update request failed (for example when updating with a
wrongly formatted date), the returned index operation type was index
instead of update.

Closes #6630
spinscale added a commit that referenced this issue Jul 2, 2014
In case an update request failed (for example when updating with a
wrongly formatted date), the returned index operation type was index
instead of update.

Closes #6630
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
In case an update request failed (for example when updating with a
wrongly formatted date), the returned index operation type was index
instead of update.

Closes elastic#6630
@lcawl lcawl added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Bulk labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v1.2.2 v1.3.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants